Implemented spec tests, improved logic in backup template