replace doNothingWriter and doNothingOutputStream with StringWriter and ByteArrayOutputStream