Modifying unit test to use CustomEvent constructor rather than document.createEvent