Fix serialization

Not sure if there are more edge cases I missed, but this change got the existing failing test to pass. It also fixes the problem I'm facing of serialization with cPickle.

I also added some cases to the old failing test just to make sure serializing lots of data types worked.