Rewrote without leaky jsdom and with kue.