Fix a bug found while unit testing, make vars protected for use with test rig
Add unit test class and include test templates