improve and fix test_wait (it used to check wrong things)