Add tests for distance #631