test and buffer refactoring