Turn the duplicated code in _generate_m2ms into loops
Fix many_to_many bridges going back to the same table

The loop only looked at the moniker name, not the key columns, so
would pick a random one. The tests didn't cover the actual self-m2m
bridge at all, so this only got noticed by the Oracle loader being
unstable in which one it picked and triggering the no-rewrite test.

Also clean up the other m2m rel tests and group them correctly.