Refactor template assertions into helper functions.