updated templates and added twig functions and tests