Slightly expand tests and fix some bugs.
Fix conflicts.