You're correct that the engines are mounted to the aircraft using only a few bolts. Usually, the engines are mounted on the wing at three points (usually two forward and one aft) with shear (or fuse) pins, with one or two bolts at each point. The DC-10, for example 6 (later 8 pins), while the 747-200 has 6.
"DC-10 engine-pylon". Licensed under Public Domain via Wikimedia Commons.
The following figure shows the engine mounting in A350 XWB, in which the aft mounting point and the load struts can be clearly seen (the first box), in which the engine is attached with two bolts.
Image from airliners.net
The shear pins have a complex cross section and are designed in such a way that it shears off in case of an impact. For example, the following figure shows the design of (three different) shear pins used in Boeing 747.
Image from FAA overview of accident involving Israeli Airlines FLT 1862
The shear pin bolt size depends on the particular aircraft and the engine combination.
As for safety factor, they are designed to break off in case the (shear) loads on them cross a certain threshold. The engine-to-wing supporting structure is designed to release the engine when extreme forces are encountered, in order to prevent any structural damage to the wing that may impair the aircraft's ability to fly. As such, their design philosophy is different from safe load design and varies from aircraft to aircraft.
Incidents have happened where the engine has separated from the aircraft due to the large forces experienced.