FIX: can read the rest of the buffer
after it's flushed now.
FIX: check arguments in Read() and Write()
refactoring (dry)
Refactoring
FIX: Read returns the number of bytes read
after a flush