fixing race conditions in tests