Issue #166 Fixed bug in discovery code and tests.