Question: Why are there passages in the Old Testament which seems to violate the moral code of Jesus and even some of our own moral sensibilities?
Answer: Because they are read out of context. The Old Testament, like any document, must be viewed contextually to be understood. It was written in a time and place far removed from ours and, more importantly, was written only to the descendants of Abraham and meant to apply only until the time of Christ. Thereafter, Christ taught us, it was to be viewed spiritually. Therefore, to suggest that certain of its injunctions be lifted from that context and applied to any people in any time and place is to mischaracterize and misrepresent it.
Christ (Messiah) is the interpreter of the Old Testament for us. He explains how it applies to our lives. This is what you see happening in the Sermon on the Mount (Matthew 5-7) and specifically, for example, in Matthew 5:17-48 and Matthew 19:3-12. Christ is teaching us to have pure hearts as He did. And through Christ our hearts can indeed be purified.
People whose view of morality consists largely of a focus on the sins that others commit (e.g. “atrocities”) have a hard time getting serious about their own personal need for moral improvement. Nonetheless, Christ can soften even these hard hearts. He has mine.