That's what I see is evident in the OT, that there were many "righteous" people, either by strong implication, or named specifically. David obviously turned from his sin and repented in a direction of "sin no more." But as you allude, he moved from a posture of "avoidance of sin" to "pursuit of God" (not that he didn't also do that earlier in life as well). And the biblical reference point for kingly excellence in their walk with God.