Template form and global template dir support
test for templates
bugfix and test refact...