Add ability to write to ioWriter and add better tests