Added some tests to rect_segment and fix small bug