I'm not exactly sure what's happening, but perhaps you should try placing markers after the borders and every time you switch from purl to knit? Then you'll know exactly when to change and you won't have to count.
And remember when you are knitting on the opposite side (the ws), you reverse the order of the knits and purls. For example:
Row 1: K5, P5, K5
Row 2 (ws): P5, K5, P5
and so forth. And, you're using circular needles but knitting flat, right? You don't want to join them and make a big tube.