Increased Test Coverage and Reduced Sonar Violations

Also which part is throwing an NPE. Because that's some bad code if we get an NPE here, and we should probably address that unless it's strictly neccessary.