factor out backoff selection, limit interval

* Factored out backoff calculation logic to enable unit testing of it
* Have upper limit (ceiling) of returned retry interval make better
  guarantees for the API user on the range of retries on less available
  reconnection targets.
improved commit hooks