added optional window to avoid requiring jsdom everytime