Treatment of electrostatic interactions in computer simulations and calculation of thermodynamic properties such as free energies and pressures