Retry delay

In case the worker has the method seconds_to_delay, the middleware uses it to perform the calculation. This makes it easier to hook into in case one needs a custom formula.

Unfortunately my other pull request commit (the first of these two commits) was the basis for getting the tests running on my machine and got included here, but it would be fine to just cherry pick the second commit.