Minor jsdom handler refactoring