
91 B.R. 83 (1988)
In re Michael B. POULE and Nancy L. Poule, Debtors.
Michael B. POULE, Appellant,
v.
REGISTRAR OF CONTRACTORS OF the STATE OF CALIFORNIA, Appellee.
BAP No. EC 87-1799 JMeAs, Bankruptcy No. BC-183-00971.
United States Bankruptcy Appellate Panel of the Ninth Circuit.
Argued and Submitted March 18, 1988.
Decided July 5, 1988.
Jerry H. Langer, San Francisco, Cal., for appellant.
June LaVerne Long, Deputy Atty. Gen., Sacramento, Cal., for appellee.
Before JONES, MEYERS and ASHLAND, Bankruptcy Judges.


*84 OPINION
JONES, Bankruptcy Judge:

FACTS
The Debtor, Michael B. Poule, d/b/a M.B. Poule Construction Co. ("Debtor"), was a general contractor, licensed by the Registrar of Contractors of the State of California, Contractors' State License Board ("Registrar"). On April 23, 1983, the Debtor filed a petition for relief under Chapter 11 of the Bankruptcy Code. The Debtor's schedules listed a debt to August Paolercio, d/b/a Shaw City Auto Parts, in the amount of $6,500.
On July 26, 1983, the Registrar issued a citation against the Debtor, finding that he had committed violations of California Business and Professions Code sections 7107, 7108, 7116 and 7119 on a project he had contracted to perform for August Paolercio in March, 1982.[1] The citation ordered the Debtor to pay $5,304.30 to Paolercio and to pay a civil penalty of $350 to the Registrar by August 30, 1983.
On August 12, 1983 the Debtor filed an appeal from the citation. The appeal was heard by an Administrative Law Judge ("ALJ") on June 27, 1984. The ALJ affirmed the citation and ordered the Debtor to pay the sums to Paolercio and the Registrar by September 6, 1984. No other disciplinary action was imposed. The ALJ order was adopted by the Registrar on August 7, 1984 and became a final order on August 22, 1984. As of that date, the Debtor had informed neither the Registrar nor the ALJ that he had filed bankruptcy. Apparently on the advice of bankruptcy counsel, the Debtor paid neither the order of corrections nor the civil penalty.
On February 26, 1985, the Registrar filed an "Accusation" against the Debtor for failure to comply with the August 22 order. On March 8, 1985, the Debtor's bankruptcy case was converted from a Chapter 11 to a Chapter 7. The Debtor filed an additional schedule on August 8, 1985, which listed the State of California as a creditor in two different capacities, neither being the debt to the Registrar. On August 23, 1985, the Debtor received his discharge. Notice of the discharge was sent to Paolercio and the Registrar on that date.
On September 6, 1985, a license revocation hearing was held before the ALJ pursuant to the Accusation that had been filed by the Registrar. Neither the Debtor nor his attorney appeared at the hearing. At the hearing, the ALJ found that the Debtor had failed to comply with the citation in that he had not paid the order of correction or the civil penalty. The ALJ recommended that the Debtor's contractor's license be revoked and concluded that:
Evidence at the instant hearing suggest [sic] that [the Debtor] has, in his capacity as an individual and in various business capacities, filed for bankruptcy in the Eastern District of California, United States Bankruptcy Court, in case number 83-00971. [The Debtor] did not identify the debts owing to the Registrar of Contractors or to Paolercio as creditors in that action. In consequence, the debt is not excused in bankruptcy.
The ALJ's proposed decision to revoke the Debtor's contractor's license was adopted by the Registrar on October 17, 1985.
On November 2, 1985, the Debtor sent a letter to the Registrar stating that the debts owed to Paolercio and the Registrar had been discharged. The Registrar treated this letter as a Petition for Reconsideration and, on November 12, 1985, denied the petition. The Registrar referred the Debtor to that portion of the ALJ's decision providing that "the debt owed the Registrar is not excusable in bankruptcy". The Debtor's contractor's license was revoked effective November 15, 1985. The Debtor did not appeal the revocation of his license.
On March 20, 1987, the California Department of Insurance denied the Debtor a license to act as a life insurance agent. The denial was based upon the revocation of the Debtor's contractor's license and *85 upon an earlier felony conviction. The Debtor contends that at a subsequent administrative hearing the sole basis for the denial was the revocation of the contractor's license.
On April 27, 1987, the Debtor filed a motion in bankruptcy court requesting that the order of the Registrar revoking the Debtor's contractor's license be set aside. The Debtor argued that because the action pending before the State License Board was subject to the Bankruptcy Code's automatic stay, the license revocation was void. The Debtor further argued that the debts to Paolercio and to the Registrar had been discharged in August 1985, two weeks prior to the license revocation hearing. The Debtor asserted that because Bankruptcy Code section 524(a)(2) enjoins the continuation of any action to collect discharged debts, the license revocation order entered as a result of his failure to pay the discharged debts was void.
The Registrar opposed the motion arguing that the hearings in front of the State License Board were excepted from application of the stay by virtue of Bankruptcy Code section 362(b)(4). The Registrar further argued that the $350 civil penalty was not discharged by the bankruptcy by virtue of Code section 523(a)(7), which excepts from discharge penalties payable to and for the benefit of a governmental unit which are not compensation for actual pecuniary loss.
On July 28, 1987, the bankruptcy judge issued an order denying the motion to set aside the order of the Registrar. In separate findings and conclusions, the judge held that the "conduct of the Registrar was exempted from the automatic stay by virtue of section 362(b)(4) as being the commencement of [sic] continuation of an action or proceeding by a governmental unit to enforce such governmental unit's police or regulatory power." In addition, the judge analogized that the instant case to Kelly v. Robinson, 479 U.S. 36, 107 S.Ct. 353, 93 L.Ed.2d 216 (1986):
It is undisputed that debtor Michael Poule had committed serious violations of the Contractors' State License Law and ample grounds existed for revoking his license. The mere fact that the Registrar gave him a chance to rehabilitate himself by making restitution and paying a fine should not enable him to evade compliance with the order of the Registrar simply by filing bankruptcy. To so hold would discourage the Registrar from ever giving a licensee a chance to rehabilitate himself through the making of restitution, the payment of fines, and other such acts.
The Debtor timely appealed.

STANDARD OF REVIEW
Resolution of this appeal requires interpretation of several provisions of the Bankruptcy Code. Questions of statutory interpretation are reviewed de novo. Trustees of the Amalgamated Ins. Fund v. Geltman Ind., Inc., 784 F.2d 926, 929 (9th Cir.1986). To the extent questions of fact are challenged, we review them under the clearly erroneous standard. Bankr.Rule 8013.

DISCUSSION
The Debtor asserts that the Registrar's license revocation based upon his failure to pay the restitution obligation and the civil fines was a violation of the automatic stay of section 362(a)(1) or the permanent injunction of section 524(a)(2). We first consider whether issuance of the citation, and the assessment of the order of corrections and the civil fines violated the automatic stay. We then consider whether revocation of the Debtor's license for failure to pay those obligations violated the permanent injunction.
A. Issuance of the Citation/Imposition of the Obligations
Filing a bankruptcy petition operates as a stay, applicable to all entities, of "the commencement or continuation . . . of a judicial, administrative, or other action or proceeding against the debtor. . . ." 11 U.S.C. § 362(a)(1). An exception to the stay appears in section 362(b)(4) for "the commencement or continuation of an action or proceeding by the governmental unit to *86 enforce such governmental units' police or regulatory powers." 11 U.S.C. § 362(b)(4). Here, the Registrar's issuance of the citation was the commencement of an administrative proceeding against the Debtor which violated the stay, unless it is within the ambit of section 362(b)(4).
There are two "tests" for determining whether government acts are within the ambit of section 362(b)(4). In In re Thomassen, 15 B.R. 907 (9th Cir. BAP 1981) we discussed the "pecuniary purpose" test. In Thomassen, the California Board of Medical Quality Assurance ("Board") initiated proceedings postpetition against one of the debtors, a physician. The proceedings were based upon allegations of (1) gross negligence or incompetence, and (2) acts of dishonesty in financial dealings. The debtors sought to have the proceeding stayed, but the trial court refused. The debtors appealed, arguing that the Board's actions were simply an attempt to force Dr. Thomassen to pay certain debts owed to persons whom he had allegedly defrauded. Id. at 909. We noted that the pecuniary purpose test distinguishes "between governmental actions which are aimed at obtaining a pecuniary advantage for the unit in question or its citizens, and those actions which represent a direct application of the unit's police or regulatory powers." Id. The aim of the pecuniary purpose test is
preventing the circumvention of the relief available to both debtors and general creditors under the Bankruptcy Code. . . . State and local governmental units cannot, by an exercise of their police or regulatory powers, subvert the relief afforded by the federal bankruptcy laws. When they seek to do so for a pecuniary purpose, they are automatically stayed, notwithstanding the exception found at [§ 362(b)(4)].
Id. We noted that the charges brought against Dr. Thomassen involved malpractice, professional incompetence, and fraud in handling patients' and employees' money. "The State's interest in this matter is in punishing such misconduct and in preventing future acts of the type which Dr. Thomassen has been accused. This is a valid police and regulatory interest." Id. at 909-910. We therefore held that the Board's actions were excepted from the stay by 362(b)(4).
The court in In re Charter First Mortgage, Inc., 42 B.R. 380 (Bankr.D.Or. 1984), considered the second test, the "public policy" test. There, the Washington State Attorney General had commenced litigation postpetition against the debtor for violating the Washington Consumer Protection Act. The Attorney General had sought injunctive relief against the debtor and restitution of monies on behalf of the debtors' victims. The debtors sought to have the Attorney General held in contempt for violating the automatic stay. The court declined, concluding that the Attorney General's actions were within the scope of section 362(b)(4). The "public policy test attempts to distinguish between those proceedings which fulfill a public policy and those which adjudicate private rights." 42 B.R. at 383 (citations omitted). Under this test, the court considers whether the administrative agency is exercising legislative, executive, or judicial functions. Where the agency's action affects only the parties immediately involved in the proceeding, it is exercising a judicial function and the debtor is entitled to the same protection from the automatic stay as if the proceeding were being conducted in a judicial form. 42 B.R. at 383-84. Turning to the facts before it, the Charter First Mortgage court concluded that it was
totally appropriate for Washington to proceed in the state court to attempt to obtain an injunction, civil penalties and attorney's fees and costs against debtor for alleged violation of its Consumer Protection Act. Such state powers are a necessary and important adjunct to its responsibilities to protect its whole citizenry from deceptive consumer practices. The authority to protect the public welfare would be largely meaningless without the power to punish and prevent. Such steps violate neither the pecuniary purpose test nor the public policy test.
42 B.R. at 384. To the extent the state sought restitution for victims of the debtor's *87 violations of the Act, however, the court held that the proceedings were not excepted from the automatic stay. 42 B.R. at 385.[2] In light of these cases, we hold that where a state agency is attempting to punish a debtor for fraudulent conduct by assessing civil penalties, or where it is attempting to prevent future occurrences of fraud through injunctive relief, the action comes within the scope of section 362(b)(4).
In the case at bar, the Debtor was charged with violations of the Contractor's Licensing Law. Cal.Bus. & Prof.Code §§ 7107, 7108, 7116, 7119. The purpose of these provisions is "to guard the public against the consequences of incompetent workmanship, imposition, and deception." Asdourian v. Araj, 38 Cal.3d 276, 282, 211 Cal.Rptr. 703, 696 P.2d 95 (1985). Moreover, the specific allegations of wrongdoing by the Debtor involve willful misconduct and fraudulent activities. The Contractor's Licensing Law is a legitimate exercise of California's police power and the acts involved in this case are of a type the state has a legitimate interest in punishing and preventing. We conclude, therefore, that the Registrar's assessment of civil penalties against the Debtor comes within the ambit of section 362(b)(4) and the penalties are valid. However, the Registrar's assessment of the order of corrections is the adjudication of private rights which, like the restitution obligation imposed in Charter First Mortgage, is not within the ambit of section 362(b)(4). The order of corrections is therefore void. See In re Sambo's Restaurants, Inc., 754 F.2d 811, 816 (9th Cir.1985) (actions taken in violation of the automatic stay are void); see also N.L.R.B. v. Edward Cooper Painting, Inc., 804 F.2d 934, 940 (6th Cir.1986) (NLRB could proceed with actions under section 362(b)(4) without court approval, but if actions later held not to be within scope of that section, they were void ab initio).
B. License Revocation
We next address whether the Registrar's revocation of the Debtor's contractor's license for failure to pay the civil penalties violated the permanent injunction against enforcement of discharged debts. See 11 U.S.C. § 524(a). Section 524(a) permanently enjoins all creditor actions to collect debts discharged under section 727. In re Aldrich, 34 B.R. 776, 779 (9th Cir. BAP 1983). Section 727(b) provides in relevant part:
(b) Except as provided in section 523 of this title, a discharge under subsection (a) of this section discharges the debtor from all debts that arose before the date of the order for relief under this chapter. . . .
We first consider whether the civil penalties "arose before the date of the order for relief". The penalties levied by the Registrar are "debts" in the bankruptcy sense. See 11 U.S.C. § 101(4), (11). Moreover, because the penalties are based upon prepetition conduct, they are treated as "arising" prepetition. See, e.g., In re Allied Mechanical Servs., Inc., 38 B.R. 959, 963 (Bankr.N.D.Ga.1984) (OSHA penalties levied postpetition, but based upon prepetition violations treated as prepetition obligation). The fact that the civil penalties were imposed postpetition, therefore, does not mean they are postpetition obligations.
We next consider whether the civil penalties are excepted from discharge by Code section 523.[3] Section 523(a)(7) provides *88 that a debt is not discharged "to the extent such debt is for a fine, penalty or forfeiture payable to and for the benefit of a governmental unit, and is not compensation for actual pecuniary loss,. . . ." 11 U.S.C. § 523(a)(7). The ALJ specifically stated that the penalties were excepted from discharge under section 523(a)(7). In addition, although the trial court did not make a specific finding on this issue, the record indicates that the judge considered the issue and implicitly found that the civil penalties levied by the Registrar come within the scope of section 523(a)(7). We agree. The penalties are payable to and for a governmental unit and they are not compensation for actual pecuniary loss. Accordingly, the permanent injunction of section 524(a) did not bar the Registrar from trying to enforce the civil penalties by revoking the Debtor's contractor's license.

CONCLUSION
We conclude (1) that the Registrar's issuance of the citation and assessment of civil penalties did not violate the automatic stay; (2) that the Registrar's assessment of the order of corrections in favor of Mr. Paolercio did violate the automatic stay; and (3) that the Registrar's revocation of the Debtor's contractor's license did not violate the permanent injunction of section 524(a) because the penalties were excepted from discharge by section 523(a)(7). Accordingly, we AFFIRM.
NOTES
[1]  The citation found that the Debtor had abandoned the project without excuse and had taken payment for materials not used on the project, compelling Paolercio to secure the services of other contractors to complete the project.
[2]  Numerous other courts have also concluded that the stay does not bar government agencies from investigating, punishing and preventing fraudulent activities by bankruptcy debtors. See, e.g., Commodity Futures Trading Comm'n. v. Co Petro Marketing Group, Inc., 700 F.2d 1279, 1283-84 (9th Cir.1983) (construing § 362(b)(5)); United States Dept. of Housing and Urban Development v. Sutton, 68 B.R. 89, 94 (Bankr.E.D.Mo.1986); In re Liss, 59 B.R. 556, 559 (Bankr.N.D.Ill.1986).
[3]  Normally, a complaint is required before a court can make such a determination. See Bankr.Rule 4007(a). Here, however, both the ALJ and the court below considered the issue without objection by the parties.
