Two hard spheres in a pore: Exact Statistical Mechanics for different shaped cavities