Added tests
Fixed wait