CmdExport refractored, asserted, commented, error handled + unit testing