Added unit testing for writing