Restore socket locking.

In light of recent revelations discussed in #254 and #256, it was probably wrong to remove socket locking for certain operations, this restores all of that.

Had to restructure the unbind test to better reflect the nature of the implementation. Sadly, this annoying locking and unlocking, which does not feel particularly zmqy or nodey, makes it very cumbersome to deal with multiple binds and unbinds to a socket. In the previous version of the unbind test, the second bind at L17 would lock the socket and cause the unrelated connect on L24 to fail. Now it waits for a to have bound to both addresses before doing anything at all, which is not elegant, but hopefully should work.