metadata packing and tests