
183 Cal.App.3d 307 (1986)
228 Cal. Rptr. 1
STANFORD W. ASCHERMAN, Plaintiff and Appellant,
v.
GENERAL REINSURANCE CORPORATION et al., Defendants and Respondents.
Docket No. A030328.
Court of Appeals of California, First District, Division Four.
June 11, 1986.
*309 COUNSEL
Robert Berg for Plaintiff and Appellant.
Skadden, Arps, Slate, Meagher & Flom, William A. Masterson and Eric S. Waxman for Defendants and Respondents.
Daniel J. Conway, Musick, Peeler & Garrett and Robert J. Feldhake as Amici Curiae on behalf of Defendants and Respondents.
OPINION
CHANNELL, J.
The trial court dismissed with prejudice appellant Stanford W. Ascherman's complaint against respondents General Reinsurance Corporation[1] and North Star Reinsurance Corporation. Ascherman appeals, contending that the trial court erred when it held that his complaint did not state a cause of action for either declaratory relief or unjust enrichment. We disagree and affirm the order of dismissal.

I. FACTS
In 1965, appellant Dr. Stanford W. Ascherman treated a patient in an allegedly negligent manner. Ascherman's patient did not discover the alleged negligence until 1977, at which time he brought a malpractice action against the doctor.
In 1965, Ascherman was insured by an Illinois company, Fidelity General Insurance Company, which, in turn, was reinsured by North Star Reinsurance Corporation. In 1970, Fidelity General had become insolvent; its assets were *310 liquidated by the Illinois Director of Insurance in accordance with Illinois law. Ascherman was advised of the liquidation proceedings and told that the last date to file a claim against the liquidated proceeds was June 1, 1971. As a condition of its reinsurance contract with Fidelity General, North Star paid certain reinsurance proceeds to the Illinois Director of Insurance. In 1979, two years after Ascherman's patient brought his malpractice action, North Star obtained a release from any further liability under the reinsurance contract. The Illinois Director of Insurance made no provision for the filing of later claims.
In 1984, Ascherman filed this action to force North Star to pay the cost of defending the malpractice action. He alleged that, by virtue of the reinsurance contract, North Star received a portion of the insurance premiums he paid to Fidelity General. He sought damages, based on a theory of unjust enrichment, and declaratory relief. North Star demurred to the complaint and asked the trial court to take judicial notice of the reinsurance contract and the release from liability. The trial court sustained the demurrer with 20 days leave to amend. When Ascherman did not amend his complaint within that time, the trial court granted North Star's motion to dismiss the action. Ascherman filed a timely appeal from the trial court's order of dismissal.[2]

II. STANDARD OF REVIEW
(1) Initially, Ascherman contends that the trial court improperly considered evidence  the release and the reinsurance contract  when it sustained the demurrer. He sets out the general rule, that a demurrer tests the pleading alone, and not the evidence or other extrinsic matter. (See 5 Witkin, Cal. Procedure (3d ed. 1985) Pleading, § 895, pp. 334-337; see also Code Civ. Proc., § 430.30, subds. (a), (b).)[3] However, he neglects to mention either the specific statutory language or the numerous other authorities that recognize that the trial court may also consider judicially-noticed matters. (§ 430.30, subd. (a);[4]Karlin v. Zalta (1984) 154 Cal. App.3d 953, 968, fn. 9 [201 Cal. Rptr. 379]; Weiner v. Mitchell, Silberberg & Knupp (1980) 114 Cal. App.3d 39, 47 [170 Cal. Rptr. 533]; Dryden v. Tri-Valley Growers (1977) 65 Cal. App.3d 990, 997 [135 Cal. Rptr. 720]; see 5 Witkin, Cal. Procedure, supra, § 896, p. 337; see also Comment, Not Looking the Complaint in the *311 Face: Judicial Notice on Demurrer (1970) 4 U.S.F.L.Rev. 433.) North Star requested the trial court to take judicial notice of the documents it cites on appeal. (See Evid. Code, § 452, subds. (c), (h).) On the basis of these authorities, both trial and appellate courts may consider evidence such as that offered below when ruling on the propriety of the demurrer.

III. DECLARATORY RELIEF
(2a) On the merits, Ascherman contends that the trial court erred when it held that his complaint did not state a cause of action for declaratory relief. He sought a declaration of the rights and duties of all parties pursuant to the reinsurance agreement. By its granting of the demurrer, the trial court implicitly found that Ascherman had no rights under the reinsurance contract. We agree with this implied finding.
Ascherman was not a party to the reinsurance contract. He contends that he is a third party beneficiary under it. (3) For a third party to qualify as a beneficiary under a contract, the contracting parties must have intended to benefit that third party, and their intent must appear from the terms of the contract. (Kirst v. Silna (1980) 103 Cal. App.3d 759, 763 [163 Cal. Rptr. 230]; see 1 Witkin, Summary of Cal. Law (8th ed. 1973) Contracts, § 501, pp. 430-431.) Thus, we examine the contract to resolve this question.
Insurance Code section 620 defines reinsurance as a "contract ... by which an insurer procures a third person to insure him against loss or liability by reason of such original insurance." (2b) A reinsurance contract is presumed to be a contract of indemnity for the benefit of the insurance company; the original insured has no interest in it. (4) (See fn. 5.) (Ins. Code, §§ 621, 623; American Re-Insurance Co. v. Insurance Com'n, Etc. (C.D. Cal. 1981) 527 F. Supp. 444, 453, fn. 15; see Excess & Cas. Reinsurance Ass'n v. Insurance Com'r, Etc. (9th Cir.1981) 656 F.2d 491, 492; Citizens Casualty Co. v. American Glass Co. (7th Cir.1948) 166 F.2d 91, 94 [construing Illinois law]; People ex rel. Baylor v. Highway Insurance Company (1974) 316 N.E.2d 633, 634.)[5] This view is consistent with that *312 expressed by insurance law scholars. (See 13A Appleman, Insurance Law and Practice (1976) Reinsurance, § 7694, pp. 527-531; 19 Couch, Cyclopedia of Insurance Law (2d ed. 1983) Reinsurance, § 80:1, p. 624.) The liability of a reinsurer depends on the terms of the reinsurance contract itself. (Royal Ins. Co. v. Caledonian Ins. Co. (1912) 20 Cal. App. 504, 506 [129 P. 597]; Fireman's F.I. Co. v. Aachen-Munich F.I. Co. (1906) 2 Cal. App. 690, 695 [84 P. 253].) (2c) The terms of this reinsurance contract reveal that it was intended to benefit the insurance company, Fidelity General, not to benefit Fidelity General's original insureds. As such, the trial court properly ruled that Ascherman did not state a cause of action for declaratory relief under the reinsurance contract.

IV. UNJUST ENRICHMENT
(5) Finally, Ascherman contends that his complaint stated a cause of action for unjust enrichment. He contends that North Star made a double recovery: it received part of the premium he paid to Fidelity General and then refused to reimburse him for legal fees and costs incurred as a result of the underlying malpractice action. Again, we disagree.
North Star was not unjustly enriched as a result of the reinsurance contract. It discharged its responsibilities under the contract and obtained a release of liability from the Illinois Director of Insurance.[6] By this action, Ascherman attempts to circumvent the Illinois statutory creditors' priorities for claims against the limited assets of insolvent companies. (See Ill. Stat. Ch. 73, ¶ 785.3, § 173.3(2) [reinsurance company may not pay claim made by policyholder against insurance company if order of liquidation has been entered against insurance company]; People v. Cosmopolitan Insurance Company (1968) 233 N.E.2d 90, 93; see also Ins. Code, §§ 922.2, 1033, 1037, 1057.) The trial court properly granted the demurrer to this cause of action.
*313 The judgment is affirmed.
Anderson, P.J., and Sabraw, J., concurred.
Appellant's petition for review by the Supreme Court was denied September 25, 1986. Bird, C.J., was of the opinion that the petition should be granted.
NOTES
[1]  Although named as a defendant below, General Reinsurance Corporation was not a party to the contract sought to be enforced and appears to have no part in the factual context of this action. We treat this case as though North Star Reinsurance Corporation is the primary respondent.
[2]  This dismissal order constitutes an appealable judgment. (Code Civ. Proc., § 581d; see Daley v. County of Butte (1964) 227 Cal. App.2d 380, 388 [38 Cal. Rptr. 693].)
[3]  All statutory references are to the Code of Civil Procedure, unless otherwise indicated.
[4]  Subdivision (a) of section 430.30 provides: "When any ground for objection to a complaint ... appears on the face thereof, or from any matter of which the court is required to or may take judicial notice, the objection on that ground may be taken by a demurrer...." (Italics added.)
[5]  "Reinsurance is a special form of insurance obtained by insurance companies to help spread the burden of indemnification. A reinsurance company typically contracts with an insurance company to cover a specified portion of the insurance company's obligation to indemnify a policyholder in the event of a valid claim. This excess insurance, as it is called, enables the insurance companies to write more policies than their reserves would otherwise sustain since [it] guarantees the ability to pay a part of all claims. The reinsurance contract is not with the insured/policyholder. When a valid claim is made, the insurance company pays the first level insured, and the reinsurance company pays the insurance company. The reinsurance company's obligation is to the insurance company, and the insurance company vis-a-vis the reinsurer is thus the insured, or more appropriately the `reinsured.'" (Excess & Cas. Reinsurance Ass'n v. Insurance Com'r, Etc., supra, 656 F.2d at p. 492, italics added.)

As a practical matter, the term "reinsurance" may also be used to denote a contract between two insurers by which the reinsurance company assumes the risk of the insurance company and becomes substituted to its contract. (See 39 Cal.Jur.3d, Insurance Contracts and Coverage, § 512, p. 844.) However, the terms of this reinsurance contract reveal that it is a true contract of reinsurance, as defined in the Insurance Code: one intended to indemnify the insurance company and not intended to benefit the original insured.
[6]  We note that Ascherman had two years before this release was issued in which to file notice that, under his interpretation of the reinsurance contract, he intended to request payment of his costs of defending his malpractice action. He did not do so.
