Simplify common code in XPath tests