Fix endianness problems outwith CRAM code

In swap_data(), for 'B' we must copy the count into  n  when it is in
host format.  In test/sam.c, the same count is in host format while we
are checking it.  Hat tip @azlicic, cf #99; partial fix for #98.