Birmingham beat Wrexham to end a three-game losing streak, and inflict more damage on Phil Parkinson's side's play-off hopes.