Fix contentstore tests and fix some bugs.