I would get the larger because you know you can fit into that, even though there may be some extra length in the legs, etc. But if small is too small, it would be impossible to comfortably wear it. You could also wash the medium in hot water and shrink it.
Absolutely go with the medium. As dogboy said, if it is too small, you can't use it. If it is too large, you can still use it.
I don't know where you are going to get the footed pajamas but there is another possibility. You can order the smaller size and if it doesn't fit, return it and get the medium. Many on-line stores allow returns just because judging sizes on-line is so hard. From personal experience, I find that for some stores, the return procedures are not worth the trouble. But this is another option.