Fix regression in templating local files

This fixes a regression in file templating, in which files on the minion's local filesystem could no longer be used as template sources. It also cleans up usage of filehandles in the file state tests.

Resolves #13873.