compilation fixes
factored out buffer impl
added test for Buffer, and a simpler reference impl