Added new test cases for iscontiguous, and fixed issues found by them

Some issues were caused by the cleanups to iscontiguous.
I've added test cases to cover them.