various fixes in utils.js

revealed by linting

- remove duplicate WrappedError definition
- remove various unused or double-declared variables
- fix some incorrect regex escaping
- add missing quotes in $('body')
- don't use assignment in while expression
This comment should presumably go, since the code it relates to is gone.