Added unit tests, and fixed a few bugs with byte_arrays