Fix setsize register issue
Write only give portion of the buffer
Fix some write() edge cases, pass test b