Merge with master and fix three unittest conflicts

For #654.