buffer_flush returns the number of items flushed

this is useful for tests, but may come in handy elsewhere
finish inital test suite

some of the tests which sleep a lot should be revisited. if we can find alternatives
which verify the same behavior and don't take so long, that'd be awesome.