Fixed #18586 -- Refactored M2m_through tests

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