combine shared code in unit tests; move reading templates into plumbing