Implemented a distance method and added a test for it.