changing error handling and test case for templates