And as you'll recall, it wasn't quite a safe transport, because Scotty materialized inside a coolant pipe. He was lucky he beamed into liquid, something that could be pushed out of the way by the ACB, instead of a solid bulkhead. (So in that sense, the film did demonstrate that it was a hazardous undertaking, not something you'd want to do routinely. I should've given the screenwriters more credit.)
When you look at the distance involved, the engineering deck really isn't very big at all compared to the surrounding vacuum of space. Mind you, Federation ships carry beacons, I suppose it's possible to lock onto that from a Federation outpost and extrapolate the coordinates of the brewery in relation to the beacon. But yes they were VERY lucky!