Ip set fix

A few issues were introduced by the cleanups to iscontiguous.
I've added test cases to cover them, and fixed the code for them.