Data race protection for tests