Make solution more general; add wider range of serialisation test cases