Fixing bug RT:378950

Mainly fixed cmd/Common.pm. Used by all other modules, my top hat fix
was breaking other calls.
Added more tests to cope with the new tophat flags.