Refactor TemplateFieldTypeMapper, write more tests