Update test.js

making templates a function for encapsulation of any logic we might want in our template