Merge pull request #25 from jandudek/rules-ordering

The latter stub rule takes precedence over the former one. Closes #18
refactoring; tests added, some variable and classes renamed etc.