Completed adaptSegments and testAdaptSegments

fixes #22