reading more the code, I think you should not just replace every invocation of releaseWakeLock with onSmsHandlerComplete, and add the call to releaseWakeLock in it (you'll need to move onSmsHandlerComplete as a function inside onSmsReceived). Only in the location where there is a "if (!document.hidden)" it's not necessary, but it also doesn't harm to do it for consistency.

Which makes me think that we might have forgot a releaseWakeLock in the `if (status === 'pending')` code ;)