add test for template casting and fix error