tpl: regexps upgraded, unit tests improved