Adding function to manage templates in ES and required tests
Small rewrite to make it easier.
Merge branch 'feature/templates'