Let generateSegments take total number of segments instead of segments per subrange

Old tests have been commented out.
New tests and safety checks for the new generateSegments

Fixed a bug subtracting RANGE_MAX instead of RANGE_SIZE to out of bound tokens.
Merge pull request #3 from spotify/Bj0rnen/totalSegmentCount

Bj0rnen/total segment count