add buffer support and fix test