I found out that the problem is about the language. I have menu and articles with Spanish language. Only Home menu item is for All languages.
I changed the article menu item for All languages, and it worked. The right Itemid is being retrieved now.
Is this a bug or is there some workaround when working with site languages?