FIxed some null reference exceptions and faulty xml
Added Unit Tests

Actually they're closer to function tests.

In addition, they are all broken see #5