Improve code coverage of unit tests.

* Test getContacts on empty bucket.
* Test market_id attribute.
* Factor kbucket creation.
* Abstract testing of getContacts.