Add tests for joining and fix a bug that got caught.