NullReferenceException bugfix for null arguments

Nasty bug introduced by @Florian in 0dfa3468 fixed. Unit test added