fixed buf in case (TC) and added unit test