Ensure tests clean up any changes made to the environment.

Fixed-up cherry pick of https://github.com/fuel/core/pull/1703

This is desirable because changes to the environment can influence
the pass/fail status of other tests, which makes them dependent on
the order in which they are executed.  This matters when running
subsets of tests with --group, or when using phpunit-randomizer,
for example.