Calculation of the static and dynamical correlation energy of pseudo-one- dimensional beryllium systems via a many-body expansion