You shouldn't have code in your application that specifically references the test environment.  The purpose of tests is to exercise the code that will be used in production.  If you're specifically routing around the real code, it's easy to miss things that won't work in real life.