fix bugs in template
change unit test