Null pointer corrected
Corrections and testing
Test extended