Ash you're not understanding.
When C acts out of turn, A and B are not acting based on C's OOT bet. They are acting on their own, doing whatever they want to do because it's their turn first. Pretending C's OOT didn't even happen.
You stated :
"I'm player B, C bets OOT, A folds, then I call the OOT bet, finally C decides to take his chips back and fold.
So i invested some chips and the first agressor C is not in the game anymore, whereas i would have checked without the OOT bet, and I can't disengage..."
There is no way that YOU as player B can CALL C's OOT bet unless you have checked first. A and B both have to act, because it's their turn before it is C's.
Once A and B have acted, then we determine what happens with C's OOT bet.
It is not possible for you to call C and then C gets the option of taking his bet back.
When C went out of turn, it was A's turn.
If A and B both CHECK, then C's out of turn bet stays. Then action comes back to A and B and they either call, raise or fold.
So whenever there is OOT action, you act like it hasn't happened. Let everyone else who's turn it actually is act, then use the rule to determine whether OOT bet stays or gets pulled back.