Make sure that the test case is run under test env

* Unset $RAILS_ENV that got set by abstract_unit to trigger the default.
* split out environment setting since Ruby 1.9.3 doesn't support inline
  ENV setting.
Merge pull request #9666 from sikachu/master-fix-test_test_failure

Make sure that the test case is run under test env