fixed broken tests.
fixed a bug in template.safeContext().