Added more tests, and fixed bug in segment class.