Refactored some byte handling, more tests working