Onions have been very effective killing intestinal parasites for me. For this reason, every time I hear someone say "I used to love onions and garlic, now I can't eat them anymore", I can't help but wonder if it upsets their stomachs because their parasites don't like them.
The stories that you posted have been circulating for years in various forms. It might just be folklore, but I think most folklore has real origins, even if it gets exaggerated as the story is passed down.