added null checks for serialization, and updated tests