Replaced 'Thread.sleep' with 'CountDownLatch' to fix the flaky test failures