completes implementation

adds implementation for setlength, position and flush. Adds tests for
set length.
updates SetLengthCore to truncate stream properly