Fix EZP-21669: Refactor and fix DiscoveryService class

JIRA issues: https://jira.ez.no/browse/EZP-21669 and https://jira.ez.no/browse/EZP-21660

Discovery Service refactored and fixed. 
Actually all of the changes made for EZP-21660 are exactly what was needed to be done in this issue, so I've just merged all those changes into this single branch.

Better to review this branch after merge of the https://github.com/ezsystems/ez-js-rest-client/pull/12 and proper rebasing.