added template test
moved a lot of initialization code to init() so tests would be successful