fix serialisation of segmentMetaDataQuery

fix serialization of segmentMetaDataQuery and add test