Refactor commands.ex to fix import issues
Update tests