Refactor and initial tests for backuptool.

### Motivation
Bringing side modules up to scratch. Most of this was actually done a long time ago.

### Changelog
* Various little code and documentation changes; see the commit message for details.
* Separation of code from tests.

### Note
This is not urgent at all, but nicely showcases some of the python idioms. Have a look.
The `reverse` was there, except it was done via a call to `reversed`, so a new list was built and the old one was discarded. It's a common anti-pattern; the new code reverses in-place.