Fig bug in split_buffer where input was being discarded

Also, write some tests for it.

Should fix #41.