Added writer and associated tests