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

Avoid reassigning function arguments; use a new name instead. Since this is a short-lived variable, `local f` is fine in my opinion. Similar for other methods below.