buffer: add some more checks to buffer filling.
tests: check proper return value from buffer test.