Fixed various unittest failures.
Fixed merge conflicts.