Refactoring the sample such that byte[], ByteBuffer, and InputStream are tested