Check for -ve offsets and lengths. This fixes the broken unit tests.