Avoid NPE
Update unit test to test null values and align with code guidelines