Update test function to use wait_for.