Remove race condition in tests