Fixing null pointer exceptions in the junit tests