fix: bug with getDirectory in Command. Add tests