Fix Writer and cover it with tests