MAINT/TST: refactor and test packbits/unpackbits

Pushes the GIL release one loop outward. First test for these functions (!).

Incorporates suggestions by @jaimefrio and @charris.