Add more explicit assertRaisesRegex test and associated compatibility code.
Correct error message for invalid partitions and fix related test cases.