Improved template engine + added unit tests