Add fail_func parameter to wait_for()

This adds the option to pass a `fail_func` function called **after** every unsuccessful try.