Refactoring: pattern match on tuple instead of using if/else
Move MTree tests to test file
Simplify exception