Add tests for ShMemObject merging. Fix a few bugs.