fixed a bug in packing function + more tests