Adding serialize implementation and tests
Merge branch 'serialize'