Improved support for functions in template, updated README, updated tests