Factorize common code of counting method handlers

3 jobs for master in 31 minutes and 42 seconds (queued for 2 seconds)
Status Job ID Name Coverage
  Test
passed #851416
build_and_run_automated_test_scenarios_with_preinstalled_image

00:14:59

passed #851415
build_and_test_with_debian_image

00:11:17

passed #851414
build_and_test_with_preinstalled_image

00:05:25