Update test cases to use waitFor().