Added Tokenizer for templates
More tests and bug fixes for Tokenizer