api: setup bare template dir for tests
hook: use fs write to improve testability