Refactor horizon TemplateLoader

Here we can use `with` statement to keep
horizon code clean.

Change-Id: I98ffc3fbcb6892a3739f2de1936c54e868f8908f
Merge "Refactor horizon TemplateLoader"