use outputStream for better testing