Refactoring TemplateAssembler and its tests.