changed serialization implementation and added some tests