fixed buf & added test code for tokenizing