Fix substring selectors being matched when cascading

Fixes substring selectors being matched when cascading. Test included.