Full tests for buff, fix bugs in original source (yay!)