Refactor the user backups code and improve test coverage