MedSafetyBench: Evaluating and Improving the Medical Safety of Large Language Models