Add the test of shortest_distance function and implement it.