nndist method and unit tests