They did until Whites became armed and organized and could defend themselves. Why do you think the line “to the shores of Tripoli” is in the Marine Hymn? Tripoli and the other Barbary pirate states were capturing and enslaving the crews of American merchant ships because unlike the French and British, we lacked warships in the Med to protect our shipping. The US built a navy and went to war with the Barbary states to stop them from enslaving our sailors, many of whom were blacks. Yes, in those days integrated ship crews were common. In fact up until WWI, the USN had fully integrated ships crews, it was only during and after the war that blacks were relegated to being cooks and stewards.