Updated test for write(ByteBuffer) and included new test for case when IO exception occurs.