[1.5.x] Fixed #20048, #20060 -- Modified tests for contrib apps sensitive to custom User models.

Thanks to matiasb for the report of #20060 and the draft patch for #20048.

(cherry picked from commit 930af661abdb4eb7322f1ab06f21df9ed04af43d)