Lightened up segments module

And added a serious amount of unit tests.