> They were used to test the bombs and make sure no such war happens again
The two cities were already on a "to be bombed" list and were the 73rd and 74th Japanese cities to be utterly destroyed by bombing.
So, Yes - they were literally used to test the bombs.
The "and make sure no such war happens again" is more of a post WWII retcon of the Cold War era.
In all likelihood, the two nuclear bombs killed fewer people than the bombing that otherwise would have occurred.