gridUtil.getTemplate bug fixes and tests