Maybe it's not an electrical issue...
To reiterate earlier comments, you may have to actually measure the voltage at the exact time it clicks to see if you have a drop in the wire. A drop would indicate a heavy load or draw and could indicate an electrical issue. If the voltage does not drop at the starter connection while measured DIRECTLY on the starter, then the starter motor is not going all the way into the engine and the heavy voltage, which makes contact only after the starter is mechanically seated into the gears, will never be applied to the actual motor armature. In all likeliness, the voltage will not drop under those conditions. This would indicate the armature is not being engaged.
If this is the case, you may have a mechanical issue with the flywheel; perhaps a damaged tooth that the starter is banging on, warped flywheel, or the face of the starter mount is misaligned, or even machined wrong, which will also cause the teeth not to mesh properly. You may have to take it to a dealer and have them inspect with a scope to determine why it doesn't engage.
The fact that it doesn't always happen indicates the battery connections are probably OK. The loose cables you have experienced is likely sloppy workmanship from whomever inspected it for the issue. (Dealer possibly)