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.
That's a valid alternative, but I don't really think it improves this part a lot (specially considering that this loop is executed once in the lifetime of the process).

NTC