implemented waitfor in tests