Refactoring: split discoverd.py into 2 modules

Wrote some missing tests as well.

Change-Id: I2d4d4619cb5825422cb2fc684f7cd028f99b991d