Changed saving methods and added tests