refactored backup agent + added tests