Adding a few waits and some better conditions for tests.