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.
In this example, tracking multiple `return`s is exactly the same as tracking the value of the `result` variable. I believe my version states the error conditions clearly. However, if you insist, I can restore the `result=[]` and put the rest of the code inside an `else` part.