test: use closed callback instead of wait()

wait() makes test fragile.