#257 skeleton and test
#257 implemented with ByteArrayOutputStream
#257 more effective implementation