Fix bugs and add TestGeoDist().