Extract environment checks to a separate file.

This is a preliminary commit to decouple TestResult from TestCase.