replaced thread.sleep with CountDownLatch in test utils