Comparison of two-dimensional and three-dimensional MHD equilibrium and stability codes