Refactor 'fleet' and 'ship' commands, and add testing helpers.