Refactor pack codec and update failing test case