In Genesis 15 we learn that Abraham believed and God counted it as righteousness. Just because Abraham has been made right with God, doesn't mean he is all the sudden perfect. Abraham will continue to grow in faith and continue to mess up. But every time he messes up, God graciously leads him back.