First of all, this is exactly the kind of question that makes me hate grammar tests: a totally decontextualised sentence, constructed not to create meaning but purely to trick the reader (in real life we write to be understood, not to show off our grammar theory!)
Honestly, the sentence looks strange to me with any option, since it's such an unnatural sentence. But if forced to choose, I'd pick D.
A:
"within" would imply "our friends" is an organisation, eg. within the army.
B:
As you said, it implies I have friends who are neither men nor women!
C:
This is the only wrong option that sounds really jarring to a native speaker. If you said A or B in casual speech nobody would notice, however this sounds really terrible. However, it's tricky to explain why.
We often use participial clauses to describe nouns, but I think the problem is that "be" is a stative verb. I'm honestly not 100% sure what the rule is about using stative verbs in participial clauses when replacing relative clauses. Sometimes it looks fine (I found a wallet containing $100), and other times it looks terrible (*I'm a guy having many friends)How about this for a "rule"? Avoid using participial clauses to describe nouns when the verb is stative, because you will sometimes be wrong.
So in conclusion...
D:
As you said, it's awful style (why would you want to specify that your friends are men and women?!), but it's the only option left after a process of elimination:
A and B are wrong, according to the rules
C might
be wrong, according to the rules (it looks instinctively horrible to a
native speaker, but I'm assuming the learner can't spot that)
I'm not English speaker.
But if that's of help, the D sounds perfect for me. A translation, word by word, to Spanish will produce a barely perfect sentence in Spanish too. Maybe if you use a verb, you need a past tense because the first part of the sentence is already in past form. But it is just a blind shot.