Fix how to compute class name on habtm namespaced.

Thank's for @laurocaetano for the help with tests. :smiley:

Fixes #14709