Shimmy is a common symptom among mollies that are living in less than ideal water conditions. Although you may have matched every factor commonly used to define your water, such as pH, ammonia, nitrite and nitrate, the fish are still being stressed. OK, so what is the problem? It is simple and easy to cure once you understand it. Mollies need a fairly high mineral content in their water. Many, perhaps all, general fish care books will recommend water that is neutral or even slightly acidic in terms of pH and that is soft. Mollies are not "typical" in that respect. Mine thrive in a pH of 7.8 in my uber hard tap water. They demand a premium at local fish club sales because they look so good. It has nothing to do with me and instead has everything to do with my tap water. If you have pet shop mollies that are experiencing a shimmy, try adding almost anything that will drive the pH and mineral content of your water higher. Sodium bicarbonate will both move pH and mineral content. Salt will move just mineral content. Other common water chemicals each also have their own impacts. Sea salt, the stuff used by people who have reef tanks, will add both pH raising chemicals and obviously add to the mineral content of water.
If you have only pet shop mollies in a tank, it is even safe to set up as reef tank chemistry in their tank. The mollies will be fine with that much mineral content in their water while the same chemistry would kill most fresh water fish. The only weakness common mollies seem to have is not to pH or similar items, but a lack of ability to cope with pure water, water with low mineral content.