Theoretical study of the trans-N2H2 -> cis-N2H2 and F2S2 -> FSSF reactions in gas and solution phases