Move the TestEnvironment class to its own file.

Fix a couple of bugs in find_netperf in the process.