Fix a few concurrency bugs and add a unit test

* Freeze lists in places so they don't change during iteration
* Make sure partitions are sorted in _rebalance. This was the
  cause of most strange behavior, like #79
* Split partition distribution logic from ``_rebalance`` and
  add some logging to make future debugging easier
* Add ``test_multiclient_rebalance`` to better simulate many
  clients connecting and then disconnecting to help ferret out
  concurrency issues.