Feature/iotcore 113 clean code

Clean some errors detected by sonar, and make tests for error conditions: wrong payloads received as requests or wrong responses from the Keystone Proxy.
another option, if you do like it

`Object.keys(errors).forEach(function(errorFn) { util.inherits(errors[errorFn],Error); })` 

or something like that ...