Partially fixing race condition in test cleanup