fixes for title and sections properties in Document
add tests and various fixes for template directive API and parsers