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

Fixed the test failures in https://github.com/Netflix/RxJava/issues/383#issuecomment-30081304 and #581