Fix trailing spaces in commands, tests for same

Previously returned an empty string parameter.