Factored out a lot of test setUp/tearDown.