build: fix race condition when building tests