Fixed a few portability and testing issues caused by recent commits.

A few extra helper functions were also added to bitwise_distance.c
These functions are currently unused and are being added in preperation for the next major commit