@Cincydawg quoted the mission history of the Nagasaki bombing above but I have long suspected that it is not accurate. If you read closely, you will note that the bomb was WAY off target and if you read more about the mission you will learn that Bockscar was running low on fuel and could not have made it back to even Okinawa if they had lingered much longer, especially with the heavy Fat Man Bomb still on board. Worse, it would have been extremely unsafe to attempt landing with the bomb on board and AFAIK they didn't have explicit permission to drop the thing over the ocean in the event of this problem.
Consequently, I have long suspected that the Bockscar crew (or just the bombardier) simply dropped it by radar without visual confirmation and that is why it ended up about 2mi away from the intended aiming point. My theory is that either:
A) The crew simply decided to ignore the order to get visual confirmation, dropped the bomb by radar, and agreed among themselves not to ever tell anyone, or
B) The bombardier got increasingly optimistic as fuel got increasingly scarce and simply thought he saw the aiming point even though he actually didn't.
Note that the Nagasaki bomb was considerably more powerful (21kt vs 16kt) and yet did less damage and killed less people because they botched the aim.
Side note:
I visited the Trinity site a few years ago (it is open to the public two days a year so check and plan ahead if you want to go). The Hiroshima bomb was, as someone above noted, untested. That was because it was a simpler design.
I'm not a physicist so I don't know this stuff very well but my limited understanding is roughly this:
In order to achieve a nuclear detonation you need to compress fissile material. The Hiroshima Bomb was a "gun type" bomb. It achieved this compression by essentially shooting a uranium bullet into a Uranium mass. This was fairly simple (to the geniuses that designed the bombs) so they didn't feel a need to test it. The Nagasaki Bomb was an implosion bomb. It was cylindrical and there were a bunch of conventional shaped charges surrounding the fissile core. Blowing up the shaped charges created the compression. They tested it first because if anything went wrong with the charges (ie, if they were not spaced correctly) the fissile material would simply blow out one side instead of detonating.
The decision not to test the gun type bomb was risky and that is why they did test the other one. If the bomb had failed to detonate the Japanese would have found it and known exactly what we were up to. Worse, they would have acquired our fissile material.