fix condition for saving HDF files + fix unit testing