NQueue and BytesWrapper bugfixes and unit tests