fix infinite loop when res.send(status) is undefined. Closes #1623