Fix places using undefined variables

Also enable jshint option "undefined" in order to catch these kind of errors in the future.

Contrary to what I said in #585, I decided to fix the problems without writing unit-tests to reproduce them. Some of the issues cannot be caught at the moment, because `test/support.js` defines global variables like `loopback` and `assert`.

This patch fixes loopback-workspace unit tests that are failing when run using the current loopback master.

/to @ritch or @raymondfeng please review
/cc @rhalff