Refactor backup, new utility functions.

And of course more tests ;)