fixed potential race condition with tests