Some fixes for null behavior

and tests!