add rules and tests
fix rules and tests
change sortIndex
Merge pull request #332 from mimmi20/issue-329

Fixes #329