fix random binary data bug, add to integration test