Add counter cache test for class_name

Backport test from #14410 to 4-1-stable

@chancancode @rafaelfranca