Added remaining TemplateDef contexts. Fixed test templates. Still TemplateDef objects are not visible within templates. refs #500