When I see code that hard-code a database name, I shudder. It must be really old code, because today I prefer to create an abstraction layer, ie. a view that references that table in the other database.
Then I have a sproc that re-creates all those views, whenever the database name changes.
I agree that it is a good idea to have similar environments, so that dev., test and production servers look and feel the same.