A methodology for studying physical and dynamical properties of multiple stars. Application to the system of red dwarfs Gl 22