Add a time limit waiting for the CountDownLatch

When the test fails, it will fail in five seconds, instead of
executing forever.