TST: refactored test_factorize
part of #23877
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`


I think I addressed all your comments @WillAyd  @jreback took care of your comment and CI is green now @jreback @WillAyd CI is green with two approvals. Can it be merged? Thanks @SaturnFromTitan 