fix end race in test