add generic segscan and test refactor