Clean up the peerDiscoveryProtocol

Fix some linting errors and reorganize some code and tests.
Merge remote-tracking branch 'origin/master'