Refactor custom matchers

This reduces the complexity by grouping checks

Change-Id: Iabdbd7cb50beb869409289918aa15005ebfe6e9b