Made tests more robust to concurrent environment.