Refactor batch allocation routines
Move the allocation and deallocation for the three states of a batch (unpacked_host, packed_host, packed_device) to separate routines. This removes duplicated code and makes the pack and unpack routines easier to read and understand. Moreover, move the computation of pack_size to the initialization because now we already know at initialization time how large a batch is. Also remove some unneeded variables.
Depends on !767 (merged).
- I have checked that my code follows the Octopus coding standards
- I have added tests for all the new features added in this request.