buffer test
Factor out buffer management