Refactoring the hashchange test to use a stub for dispatchEvent calls