Correct a typo resulting in switched partitioning.

Thanks to @xuwei-k for pointing this out. Added additional tests to check this
more thoroughly.

Signed-off-by: Gary Pamparà <gpampara@gmail.com>