Improve null handling

Add more tests for literal serialization

Fixes #1079