Add middleware test
Use more reliable res.headersSent