Fix race in tests