Refactor discoverer from cli

I'm hoping this doesn't open a new PR and appends #48.  I've broken out the tests for @shobhitic's changes, which required a little refactoring.