WIP: Fix state leaks in tests.

This will allow us to run the tests in random order.