added some tests, code polishing, osa method gains maxDist