fix a bug of pack(), write tests