Updated to support Express 4.x

Express 4.x no longer represents res.locals as a function, this fix allows the treatment of res.locals as an object for 4.x and keeps backwards compatibility in 3.x and 2.x.

This also fixes up race conditions in express-test.js