Get rid of race condition in tests