Lithium batteries produced by reliable and noted manufacturers would have undergone the mandatory UN Tests.
However those that had been purchased through Internet auction or cheap copies would most likely have avoided the UN Tests. These if overcharged can accumulate heat, explode and catch fire. When batteries are installed in the apparatus, they are protected by the strong outer casing of the apparatus itself. Spare lithium batteries are in most cases enclosed in thin cardboard boxes or sometimes packed bare with no protection. If it is not protected, when it catches fire, it can easily ignite nearby combustible items. If loaded in the cargo compartment, such fire can spread before the crew notices the fire.
If this happens in the cabin, the crew can immediately attend to the fire. Particularly with lithium batteries used in personal portable electronic devices, chances are that the passenger would be tempted to purchase cheap batteries which most likely would not have passed the UN Test. Batteries which have not been UN tested are prohibited from air carriage. There are many cases where such batteries have overheated, exploded and caused fire. Lithium batteries must be purchase from reliable vendors.