Test and Refactor MKD/RMD

This PR adds complete test coverage for the MKD and RMD commands. It subsequently refactors the command code. JSDOC documentation has also been added for each command.  Detailed comments can be found in the corresponding commit messages.