Fix for #422 on the 1.7.

Also took the opportunity to reorganize some of the unittests a little
bit.