Refactored command building and wrote tests based on the readme