
563 N.W.2d 605 (1997)
Gregory R. SCHAFFER d/b/a Gregory R. Schaffer Construction, Appellant,
v.
FRANK MOYER CONSTRUCTION, INC., Appellee.
No. 96-366.
Supreme Court of Iowa.
May 21, 1997.
*606 Catherine Dietz-Kilen and Harvey L. Harrison of Harrison & Dietz-Kilen, Des Moines, for appellant.
John Haraldson and Robert J. Kuhle of Law Office of Robert J. Kuhle, P.C., West Des Moines, and David L. Wetsch, Des Moines, for appellee.
Considered by McGIVERIN, C.J., and LARSON, CARTER, SNELL, and TERNUS, JJ.
CARTER, Justice.
Gregory Schaffer, a finish carpentry contractor for the construction of a new home, appeals from a judgment dismissing his action to foreclose a mechanic's lien. In sustaining a motion to dismiss the petition, the district court concluded that Schaffer's lien was unenforceable because the property was an owner-occupied dwelling, and he had *607 not given notice to the owners as required by Iowa Code section 572.14(2) (1995) prior to the time that the primary builder, defendant Frank Moyer Construction, Inc. (Moyer), had been paid in full. Schaffer urges that this statute does not affect the enforceability of his lien because Moyer had legal title to the property during the time Schaffer's work was performed and continued to hold that title until nine days after the filing of Schaffer's petition to foreclose the lien. After reviewing the record and considering the arguments of the parties, we reverse the judgment of the district court.
A motion to dismiss tests the legal sufficiency of a plaintiff's petition. Such motions are properly granted only if plaintiff's petition "on its face shows no right of recovery under any state of facts." Tate v. Derifield, 510 N.W.2d 885, 887 (Iowa 1994). A motion to dismiss admits well-pleaded facts and waives ambiguity or uncertainty in the petition. Id. Allegations in the petition are viewed in a light most favorable to the plaintiff. Id. Facts not alleged cannot be relied on to aid a motion to dismiss nor may evidence be taken to support it. Stearns v. Stearns, 187 N.W.2d 733, 734 (Iowa 1971).
In sustaining the motion to dismiss in the present case, the district court relied on Schaffer's concession that he had not served a notice of the type designated in section 572.14(2) on the persons who bought the home from the builder. It appears from the record that these persons, Steven Hartung and Michelle LaMasters, acquired the house from Moyer by warranty deed dated November 17, 1995, and filed of record with the Polk County recorder on that date. Schaffer has alleged in his petition that his work on the house was performed during the months of June, July, and August of 1995. He alleges his contract was with Moyer, the record titleholder until November 17. Schaffer filed his mechanic's lien on October 3, and on October 23, Moyer filed a demand for bringing suit pursuant to section 572.28. Hartung and LaMasters have at no time been parties to the present action.
Section 572.14(2) provides:
In the case of an owner-occupied dwelling, a mechanic's lien perfected under this chapter is enforceable only to the extent of the balance due from the owner to the principal contractor at the time written notice, in the form specified in subsection 3, is served on the owner. This notice may be served by delivering it to the owner or the owner's spouse personally, or by mailing it to the owner by certified mail with restricted delivery and return receipt to the person mailing the notice, or by personal service as provided in the rules of civil procedure.
An "owner-occupied dwelling" is defined as follows:

"Owner-occupied dwelling" means the homestead of an owner, as defined in section 561.1, and without respect to the value limitations in section 561.3, and actually occupied by the owner or the spouse of the owner, or both. "Owner-occupied dwelling" includes a newly constructed dwelling to be occupied by the owner as a homestead, or a dwelling that is under construction and being built by or for an owner who will occupy the dwelling as a homestead.
Iowa Code § 572.1(4).
In Louie's Floor Covering, Inc. v. DePhillips Interests, Ltd., 378 N.W.2d 923 (Iowa 1985), we held that one who contracted with a home builder for the purchase of a lot owned by the builder and a house to be constructed thereon was an owner of the property so as to render a floor covering contractor dealing with the builder a subcontractor rather than a primary contractor. We further held that the property fell within the definition of an owner-occupied dwelling as a result of the language of section 572.1(4) that extends such status to "a dwelling that is under construction and being built by or for an owner who will occupy the dwelling as a homestead."
The appellee argues that the present dispute is so similar to the Louie's Floor Covering case that a similar result must prevail. We disagree. There are two significant distinctions between the present case and Louie's Floor Covering. First, there is nothing in the present record to suggest that Hartung and LaMasters had any ownership *608 interest in the property prior to the November 17 deed. In Louie's Floor Covering, the persons for whom the house was being built were the equitable owners as contract vendees. Although a literal reading of the definition of owner contained in section 572.1(3) would allow one for whose benefit the building or improvement is being made to be an owner, irrespective of any ownership interest in the real estate, we find such interpretation to be untenable.
Under the statutory scheme found in chapter 572, owners are the persons against whose interest the lien is asserted. It would thus be a useless exercise to authorize a lien against a statutorily defined "owner" who holds no legal interest that can be foreclosed upon in a property-law sense. The definition of owner-occupied dwelling contained in section 572.1(4) extends to property that will not be occupied as a homestead until some time in the future. We are unable to conclude, however, that this definition embraces property in which the prospective occupant has no vestige of ownership prior to the time the lien is perfected against a record owner who has contracted for the lienor's services and who does not intend to occupy the property as a homestead.
Because the present case was decided on a motion to dismiss, facts could come forward at trial showing that Hartung and LaMasters did have equitable title to the property prior to the time the lien was perfected against their vendor's interest. That may not be presumed from the present record, and the district court's ruling may not stand.
A second point that distinguishes this case from Louie's Floor Covering is the fact that in that case and the later case of Carson v. Roediger, 513 N.W.2d 713 (Iowa 1994), the mechanic's liens that were the subject of dispute were not filed until after the buyers had paid the primary contractor. In the present case, Schaffer's lien was of record before payment to Moyer is alleged to have been made.
We are convinced that it was the purpose of section 572.14(2) to protect an owner-occupier from potential subcontractor liens that might be timely perfected after payment has been made to the primary contractor by the owner-occupier. That danger existed by reason of the ninety-day period permitted for the filing of subcontractor liens under section 572.9. To interpret section 572.14(2) as also precluding enforcement of liens that are filed and fully perfected against a record titleholder contracting for the work prior to the time that the alleged owner-occupier has paid for the property would, in our view, extend the protection of the statute beyond that which was intended.
As a final matter, we note that no judgment in the present case can be fully effective unless the interests of Hartung and LaMasters are adjudicated in an action in which they have been made parties. They thus fall within the purview of the rule that provides:
When persons are not before the court who, although not indispensable, ought to be parties if complete relief is to be accorded between those already parties, and when necessary jurisdiction can be obtained by service of original notice in any manner provided by these rules or by statute, the court shall order their names added as parties and original notice served upon them.
Iowa R. Civ. P. 25(c).
For the reasons stated, we reverse the judgment of the district court and remand the case to that court for further proceedings consistent with this opinion.
REVERSED AND REMANDED.
