First, there is some confusion on your part about heart cells and pain perception. Heart cells generate an action potential intrinsically; they do not need the central nervous system to beat (your second article explains this; read the part about the importance of calcium.) So yes, long before a fetus can feel pain, the heart is beating, because there must be circulation of nutrients throughout the embryo.
Secondly, the vagus nerve and sympathetic nerves can affect heart rate (the former by slowing it down when firing). These nerves start to reach their endpoints late in week 4 of development. So 19 days is not correct.
Cardiac sympathetic system
Although the primitive human heart starts to beat at 21 to 22 d, heart development continues to day 50, and it is near the end of this period, during the fifth week, that thoracic neural crest cells migrate from the neural tube through the somites and form aggregations (ganglia) near the dorsal aorta. [emphasis mine]
To experience pain, however, requires maturation of certain parts of the brain, most importantly, part of the thalamus and the cerebral cortex:
Current theories of pain consider an intact cortical system to be both necessary and sufficient for pain experience. In support are functional imaging studies showing that activation within a network of cortical regions correlate with reported pain experience. Furthermore, cortical activation can generate the experience of pain even in the absence of actual noxious stimulation. These observations suggest thalamic projections into the cortical plate are the minimal necessary anatomy for pain experience. These projections are complete at 23 weeks' gestation. [emphasis mine]
Fetal surgeons and anesthesiologists often use 20 weeks as the time at which a fetus can start to feel pain, because that is when the fetus reacts to stimuli that would be recognized as pain if applied to adults (e.g. recoiling from noxious stimuli.)
One must recognize that recoiling from noxious stimuli does not prove what the fetus is perceiving. But it's a step in the direction of protecting the fetus from unnecessary pain.
Autonomic cardiac innervation: Development and adult plasticity
Can fetuses feel pain?