Add sanity check tests.

This PR adds tests for the ``sanitycheck`` module. 

It documents a bug fixed in @ad104e4a9cc3fd8bd7271ccc1ec37103e9606d05 and adds some further tests.