Use Bash -e shell option instead of many exits

The result is the same, but this removes unnecessary code and avoids
forgetting to add an exit command to a line.
Prevent failure with old versions of losetup
Fix check for losetup version

Before, the test always evaluated to true and kpartx was used. Now, the
test actually depends on the value of `losetup_lt_2_22`.