Better isolation for unit tests.

Because of our use of statics, unit tests are leaking static state and this causes tests to fail randomly based on running order.