[WIP/RFC] Add unit tests for buffer.c and fileio.c

This seems like a bug to me, but the purpose of this pull is to document current behavior.