Added Unit Tests
Added Unit Tests, fixed lots of segfaults