Add tests for nested grain/pillar matching

Also added tests for traditional grain matching when target grain is a
list.
Merge pull request #3459 from archtaku/tests

Add tests for nested grain/pillar matching