Fix EZP-21669: Refactor and fix DiscoveryService class