tests refactoring, separate reading and writing test