Refactor getDomHead in tests