Add test for race conditions