From brane dynamics to a Kac-Moody invariant formulation of M-theories