#1 add templating

- updates; added unit tests; bug fixes