
563 S.E.2d 755 (2002)
264 Va. 210
Loretta W. FAULKNIER
v.
Linda D. SHAFER.
Record No. 012006.
Supreme Court of Virginia.
June 7, 2002.
*756 Adrienne George-Eliades (Hill, Rainey & Eliades, on brief), for appellant.
Robert L. Flax (Flax & Stout, on brief), Richmond, for appellee.
Present: All the Justices.
KINSER, Justice.
This appeal involves a dispute over the proceeds of a life insurance policy that were paid to Linda D. Shafer, the named beneficiary on the policy, allegedly in contravention *757 of a separation agreement between the decedent and his former wife, Loretta W. Faulknier. Because we conclude that Faulknier alleged sufficient facts to state a cause of action for the imposition of a constructive trust on the insurance proceeds, we will reverse the circuit court's judgment sustaining a demurrer.

FACTS AND MATERIAL PROCEEDINGS
The circuit court decided this case on demurrer. Therefore, we "recite as true the well-pleaded facts." Thompson v. Skate America, Inc., 261 Va. 121, 125, 540 S.E.2d 123, 124 (2001). In doing so, we look solely at Faulknier's allegations in her bill of complaint, see Perk v. Vector Resources Group, Ltd., 253 Va. 310, 312, 485 S.E.2d 140, 142 (1997), and any exhibits mentioned in the challenged pleading, Rule 1:4(i); Flippo v. F & L Land Co., 241 Va. 15, 17, 400 S.E.2d 156, 156 (1991).[1]
The marriage between Faulknier and the decedent was dissolved by a decree of divorce entered in June 1989. A separation agreement that Faulknier and the decedent had previously executed was filed with that decree[2] As pertinent to this appeal, the separation agreement provided that "[Faulknier] shall remain as beneficiary on [the decedent's] Civil Service Life Insurance[.]" However, in 1996, the decedent designated Shafer as beneficiary of that policy.
After the decedent's death in 1997, Faulknier filed a claim for the proceeds of that life insurance policy. The Office of Federal Employees' Group Life Insurance denied the claim because "THE LATEST DESIGNATION OF BENEFICIARY ON FILE THAT WAS COMPLETED BY THE INSURED ON 02/20/96 NAME[D] SOMEONE OTHER THAN [FAULKNIER] AS BENEFICIARY."
Faulknier then filed a bill of complaint against Shafer to recover the proceeds of the decedent's life insurance policy. Faulknier alleged that the decedent changed the beneficiary designation on his life insurance policy in contravention of the separation agreement. Continuing, she asserted " that Shafer received those insurance proceeds upon the decedent's death because she was the named beneficiary at that time and that, either before or upon receipt of the funds, Shafer "knew or expected, or reasonably should have known or expected, that her designation as beneficiary of the Insurance Plan violated the terms of the Separation Agreement." Faulknier alleged that Shafer, therefore, has been unjustly enriched and "wrongfully has obtained payment of benefits" under the decedent's life insurance policy that "rightfully belong to Faulknier" under the terms of the separation agreement. Faulknier asked the court, among other things, to impose a constructive trust on those funds.
In response, Shafer filed a demurrer asserting that Faulknier must seek redress against the decedent's estate before pursuing an equitable remedy.[3] Shafer argued that, because the decedent's estate had sufficient assets to satisfy Faulknier's claim, Faulknier could proceed against the estate either in an action for breach of contract, see Code § 64.1-144, or by requesting a "debts and demands" hearing before the commissioner of accounts pursuant to Code § 64.1-171. Therefore, according to Shafer, Faulknier had an adequate remedy at law and was not entitled to the imposition of a constructive trust upon the life insurance proceeds paid to Shafer.
Faulknier subsequently moved for summary judgment asserting that the undisputed facts demonstrate that Shafer had been unjustly enriched at Faulknier's expense. Thus, Faulknier claimed that a constructive trust should be imposed on the life insurance *758 proceeds, even if Shafer was unaware of the terms of the separation agreement and innocently received payment of those benefits.
After considering the parties' arguments, the circuit court granted Shafer's demurrer and denied Faulknier's motion for summary judgment. The court subsequently entered an order dismissing Faulknier's suit without prejudice and she now appeals.

ANALYSIS
On appeal, Faulknier asserts that the circuit court erred as a matter of law in finding that she must seek redress against the decedent's estate in order to recover the proceeds of the life insurance policy. She also assigns error to the court's conclusion that she was not entitled to summary judgment since the uncontroverted evidence, according to Faulknier, demonstrates that Shafer was not entitled to the proceeds of the life insurance policy and will be unjustly enriched if she is allowed to retain those funds. We will first decide whether the circuit court erred in sustaining Shafer's demurrer and then consider whether the court also erred in denying summary judgment to Faulknier.
With regard to the first issue, the procedural posture of this case is important because the function of a demurrer is to test only whether the challenged pleading states a cause of action upon which relief can be granted if all the allegations are admitted as true. Bellamy v. Gates, 214 Va. 314, 315-16, 200 S.E.2d 533, 534 (1973). See also Votsis v. Ward's Coffee Shop, 217 Va. 652, 654, 231 S.E.2d 236, 237 (1977). In ruling on the demurrer, the circuit court "was required to consider all reasonable inferences of fact which fairly and justly could be drawn from the facts alleged." Ryland Group, Inc. v. Wills, 229 Va. 459, 461, 331 S.E.2d 399, 401 (1985) (citing Chippenham Manor, Inc. v. Dervishian, 214 Va. 448, 450, 201 S.E.2d 794, 796 (1974)). "[Al plaintiff challenging on appeal the sustaining of a defendant's demurrer by the trial court need show only that the trial court erred in finding that the pleading failed to state a cause of action, and not that the plaintiff would have prevailed on the merits of that cause." Thompson, 261 Va. at 128, 540 S.E.2d at 127. These same principles guide our review of the allegations in Faulknier's bill of complaint.
In deciding whether those allegations are sufficient, as a matter of law, to state a cause of action upon which the requested relief could be granted, we must also consider well-established principles regarding the imposition of constructive trusts.
Constructive trusts arise, independently of the intention of the parties, by construction of law; being fastened upon the conscience of him who has the legal estate, in order to prevent what otherwise would be a fraud. They occur not only where property has been acquired by fraud or improper means, but also where it has been fairly and properly acquired, but it is contrary to the principles of equity that it should be retained, at least for the acquirer's own benefit.
Leonard v. Counts, 221 Va. 582, 589, 272 S.E.2d 190, 195 (1980) (quoting 1 Minor on Real Property § 462 at 616 (2d ed. Ribble 1928)). Courts of equity may impose constructive trusts whenever necessary to prevent a failure of justice. Richardson v. Richardson, 242 Va. 242, 245, 409 S.E.2d 148, 150 (1991) citing Patterson's Ex'rs v. Patterson, 144 Va. 113, 123, 131 S.E. 217, 220 (1926)).
When property is given or devised to a defendant in breach of a donor's or testator's contract with a plaintiff, equity will impose a constructive trust upon that property in the hands of the recipient even though (1) the transfer is not the result of breach of a fiduciary duty or an actual or constructive fraud practiced upon the plaintiff, and (2) the donee or devisee had no knowledge of the wrongdoing or breach of contract.
Jones v. Harrison, 250 Va. 64, 69, 458 S.E.2d 766, 769 (1995).
Shafer argues, however, as she did before the circuit court, that Faulknier has an adequate remedy at law because the decedent's estate is solvent and contains sufficient assets to satisfy Faulknier's claim. Relying on Jones, Shafer contends that Faulknier must therefore pursue her contractual claim against the estate pursuant to either Code § 64.1-144 or § 64.1-171 before she can seek *759 the equitable remedy of imposing a constructive trust on the life insurance proceeds. We are not persuaded by this argument and conclude that our decision in Jones is not controlling authority because of the procedural posture of the present case vis-à-vis that in Jones.
This Court held in Jones that the provisions of a property settlement and support agreement entitled the children of a decedent's former marriage to a constructive trust on the proceeds of life insurance policies payable to the decedent's second wife, even though there was no evidence that the second wife had done anything improper, had participated in the decedent's breach of the support agreement, or had knowledge of that breach. 250 Va. at 69-70, 458 S.E.2d at 769-70. See also Richardson, 242 Va. at 246-47, 409 S.E.2d at 151 (constructive trust imposed where transferee, who had not engaged in any wrongdoing and had furnished no consideration for the transfer, was unjustly enriched). Thus, we concluded that "because the other elements necessary to establish a constructive trust [were] present, the [second wife's] gratuitous receipt of a portion of the insurance proceeds forms the basis for imposing a constructive trust on that property." Jones, 250 Va. at 70, 458 S.E.2d at 770. In a footnote, we explained that the children had a contractual claim against the decedent's estate, but because the estate was insolvent, the children could claim a constructive trust in a portion of the proceeds of the insurance policies. Id. at 70 n. 3, 458 S.E.2d 766, 458 S.E.2d at 770 n. 3.
The statement in that footnote forms the basis of Shafer's contention that Faulknier must first seek redress from the decedent's estate. However, we decided Jones by reviewing the findings of a commissioner in chancery who had heard evidence. Id. at 67, 458 S.E.2d at 768. In contrast, the present case comes to us on a judgment sustaining a demurrer. Shafer's assertion that the estate in the present case is solvent is based solely upon documents that she appended to her memorandum in support of the demurrer. Those documents were not mentioned in Faulknier's bill of complaint. See Rule 1:4(i). Thus, we will not consider them in deciding whether the allegations in the bill of complaint state a cause of action. See Flippo, 241 Va. at 17, 400 S.E.2d at 156.
Relying on Overby v. White, 245 Va. 446, 449, 429 S.E.2d 17, 19 (1993), Shafer also argues that the imposition of a constructive trust is warranted only when the recipient of funds obtained them in some wrongful way. She asserts that she had no knowledge of the decedent's beneficiary designation or separation agreement before he died. Based on that assertion and because there is no allegation that she colluded with the decedent, induced him to change his beneficiary designation, or otherwise acted with the intention of depriving Faulknier of the insurance proceeds, Shafer contends that impressing a constructive trust in this case in inappropriate.
Our decision in Overby is not dispositive of the issue before us. There, the plaintiff sought to have the court impress a constructive trust on an interest in property that the defendant had properly acquired before the conduct warranting a constructive trust had occurred. Id. at 447-48, 429 S.E.2d at 18. In contrast, Shafer did not acquire the life insurance proceeds before the decedent breached the terms of his separation agreement with Faulknier. We noted this same distinction in our decision in Jones. 250 Va. at 69, 458 S.E.2d at 769. Furthermore, our decision in Overby was not premised solely on the fact that the defendant had not engaged in any wrongdoing. Overby, 245 Va. at 450, 429 S.E.2d at 19. We have repeatedly stated that constructive trusts can arise even when property has been acquired fairly and without any improper means. See, e.g., Jones, 250 Va. at 70, 458 S.E.2d at 770; Nedrich v. Jones, 245 Va. 465, 474, 429 S.E.2d 201, 206 (1993); Richardson, 242 Va. at 245, 409 S.E.2d at 150; Leonard, 221 Va. at 589, 272 S.E.2d at 195.
Thus, we conclude that the circuit court erred in sustaining Shafer's demurrer. Faulknier pled facts which, if taken as true, are sufficient to state a cause of action for the imposition of a constructive trust on the basis that Shafer has been unjustly enriched. "A constructive trust is appropriately imposed to avoid unjust enrichment of a party." Cooper v. Cooper, 249 Va. 511, 517, 457 *760 S.E.2d 88, 92 (1995) (citing Leonard, 221 Va. at 589-90, 272 S.E.2d at 195-96); see also Restatement of Restitution § 160 (1937).
Issues such as whether the decedent's estate has sufficient assets to satisfy Faulknier's claim, and if so, whose share of the estate would be depleted by such a payment;[4] whether Shafer was a gratuitous recipient of the life insurance proceeds;[5] when she learned about the decedent's beneficiary designation on his life insurance policy; and whether she knew about the terms of the separation agreement between the decedent and Faulknier are matters to be considered in determining whether, on remand, Faulknier establishes by clear and convincing evidence her entitlement to a constructive trust on the life insurance proceeds.[6]See Cooper, 249 Va. at 517, 457 S.E.2d at 92 ("constructive trust must be established by clear and convincing evidence"); Ogden v. Halliday, 235 Va. 639, 643, 369 S.E.2d 417, 419 (1988)(same). Because proof of these issues has a bearing on whether Shafer has been unjustly enriched and whether a constructive trust is appropriate in this case, we also conclude that the circuit court did not err in denying Faulknier's motion for summary judgment.
For these reasons, we will affirm in part and reverse in part the judgment of the circuit court and remand this case for further proceedings in accordance with this opinion.[7]
Affirmed in part, reversed in part, and remanded.
NOTES
[1]  Faulknier attached two exhibits to her bill of complaint: a separation agreement and a letter from the Office of Federal Employees' Group Life Insurance.
[2]  The decree of divorce did not "affirm, ratify and incorporate by reference" the separation agreement. Code § 20-109.1.
[3]  Shafer also filed an answer denying any indebtedness to Faulknier and a cross-bill seeking indemnification from the `decedent's estate for any sum owed by her to Faulknier.
[4]  See Green v. Green, 13 Mass.App.Ct. 340, 433 N.E.2d 92, 93 (1982) (trial court's ruling that estate was primarily liable exhausted plaintiffs' share of estate in partial satisfaction of their claim to insurance proceeds).
[5]  We note that Shafer admitted, in response to Faulknier's request for admissions, that she provided no monetary consideration for the decedent's designation of her as the beneficiary of his life insurance policy. As with the documents disclosing the estate's assets, we do not consider this admission when reviewing the judgment sustaining the demurrer.
[6]  On brief, Shafer asserted that Code § 38.2-3122 allows her to receive the life insurance proceeds free of any claim by a creditor, such as Faulknier. In her demurrer before the circuit court, Shafer did not argue that this Code section bars Faulknier's claim. Pursuant to the provisions of Rule 5:25, we do not consider arguments raised for the first time on appeal.
[7]  Neither party addressed whether any provision of federal law, including 5 C.F.R. §§ 870.801 or 870.802, affects the validity of the decedent's beneficiary designation for his life insurance proceeds or the imposition of a constructive trust on those proceeds.
