Refactorings and tests for the base macro for defining commands.