Improved testing

Added several simple unit tests and have modified distance code to be
accurate to a given precision to mitigate rounding errors.