trailing blanks removed, adapted do_rules for tests, return values
first test for do_rules works, more shall come...