Fix flaky tests by adding a custom matcher

- when checking maps of Cardinalities we need to make sure we have a
  internally a tolerance when comparing doubles
Merge pull request #3640 from davidegrohmann/2.2-fix-flaky-test

Fix flaky tests by adding a custom matcher