fixed unit tests
improved template construction