Refactored m2m_through tests. Refs #18586

Refactored old tests that were rewritten 1:1 from doctests.