sets aren't ordered but you seem to use the return values in an iteration. This should be a list instead.

Also, can you put these functions into the check command class? There is no need to offer them as module level functions.