tests + refactoring for template tags