added template.js and some tests