All perfect praise be to Allah, The Lord of The Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
The bequest is a donation given after death and the permitted amount for making donation from it, is one third only, since Sa`d bin Abi Waqqas: "In the year of the last Hajj of the Prophet (PBUH) I became seriously ill and the Prophet (PBUH) used to visit me inquiring about my health. I told him: "I am reduced to this state because of illness and I am wealthy and have no inheritors except a daughter, Should I give two-thirds of my property in charity?' He said: "No.' I asked, 'Half?' He said: "No.' then he added: "One third, and even one-third is much. You'd better leave your inheritors wealthy rather than leaving them poor, begging others.” [Agreed upon].
Therefore, the bequest has to be fulfilled before the distribution of inheritance and what remains after that, should be distributed among the heirs, so if the deceased bequeathed an amount of his inheritance to the poor and needy, then they aren’t permitted to inherit this amount even if they were poor or needy because the bequest wasn’t made for them in the first place. In addition, Allah has appointed for everyone who has a right what is due to him. In this regard, Abu Umamah al-Bahili (May Allah be pleased with him) narrated: I heard Allah's Messeneger (PBUH) saying: "Allah has appointed for everyone who has a right what is due to him, and no Wasiyah (will) should be made to an heir." [Related by Abu Dawood].
Moreover, Ibn Hajer Al-Haythamy (May Allah have mercy on his soul) said: ”The heirs aren’t permitted to take the amount allocated to the poor within the bequest even if they were poor, further Al-Shafiee stated: ”if it the deceased bequeathed to give one third to a person in order to give that third on behalf of the deceased for the sake of Allah, then neither he nor the heirs are permitted to take any sum of the one third because the bequest wasn’t meant for them, rather it was meant for the sake of Allah, so the aforementioned person should dispense of the one third on acts of obedience for which the deceased will be benefit of.” [Tohfat Al-Muhtaj vol.7 pp.16]. And Allah Knows Best.