fix up race conditionsi n the tests