Fix and test MDTM command

This PR addresses the following issues for the `MDTM` command:
- confine command to CHROOT jail
  - more at asylumfunk#28
- refactor
- add test coverage

It has been split into multiple commits to highlight each changeset. Please refer to each commit for a detailed explanation of the change, the reasoning, and the impact.