Unit test cleanup

Reduce background errors and concurrency issues in unit tests.