<PAGE>

                                                                   EXHIBIT 10.51

                    AMENDMENT TO LOAN AND SECURITY AGREEMENT

      This Amendment to Loan and Security Agreement (this "Agreement") is
entered into as of May 20, 2002, by and between COMERICA BANK-CALIFORNIA
("Bank") and PHARMCHEM, INC. (the "Borrower"), with reference to the following
facts:

      A. Borrower has borrowed funds from Bank pursuant to that certain Amended
and Restated Loan and Security Agreement by and between Bank and Borrower dated
as of May 15, 2000, as amended by an Amendment to Loan and Security Agreement
and Limited Waiver dated as of September 12, 2001, a Modification to Amended and
Restated Loan and Security Agreement dated as of May 25, 2001, and by an
Amendment and Forbearance dated as of March 1, 2002 (the "Loan Agreement").

      B. As of the date hereof, there is owing under the Loan Agreement a
principal amount of $3,305,343.99 together with accrued but unpaid interest and
costs of enforcement. Such amounts, plus accruing interest and costs and accrued
and accruing attorneys' fees and costs are hereinafter sometimes referred to
herein as the "Existing Debt."

      C. Borrower has asked Bank to amend certain provisions of the Loan
Agreement, and Bank has agreed, all on the terms set forth in this Agreement.

      NOW, THEREFORE, for good and valuable consideration, the parties agree as
follows:

      1. Defined Terms. Capitalized terms not otherwise defined herein shall
have the same meanings as set forth in the Loan Agreement.

      2. Acknowledgement of Liability. As of the date of this Agreement,
Borrower owes Bank an amount equal to the Existing Debt. Borrower reaffirms all
of its obligations under the Loan Agreement and hereby forever waives and
relinquishes any and all claims, offsets or defenses that Borrower may now have
with respect to the payment of sums due to Bank and the performance of other
obligations under the Loan Agreement. The security interests granted to Bank in
the Loan Agreement in the Collateral remain perfected, first priority liens.

      3. Amendments to Loan Agreement. The Loan Agreement is hereby amended as
follows:

            (a) The following defined terms in Section 1.1 are amended to read
as follows:

                  "Borrowing Base" means an amount equal to eighty percent (80%)
      of Eligible Accounts, as determined by Bank with reference to the most
      recent Borrowing Base Certificate delivered by Borrower.

                  "Committed Revolving Line" means a credit extension of up to
      Four Million Two Hundred Fifty Thousand Dollars ($4,250,000).

                  "Revolving Maturity Date" means June 30, 2002.

            (b) The second sentence of Section 4 of the Amendment and
Forbearance dated as of March 1, 2002 by and between Borrower and Bank is
deleted.


                                       1
<PAGE>

            (c) A new Section 6.17 is added to the Loan Agreement, which shall
read as follows:

                  6.17 Liquidity. Borrower shall maintain at all times a balance
of unrestricted cash of at least One Million Dollars ($1,000,000).

      4. Ratification by Borrower of Bank's First Priority Security Interest in
Collateral. Borrower hereby confirms and ratifies Bank's first priority lien and
security interest in and to all Collateral. Borrower shall execute such security
agreements, financing statements and other documents as Bank may from time to
time reasonably request to carry out the terms of this Agreement and the Loan
Agreement. Such liens and security interests shall secure all of the obligations
of Borrower under this Agreement and the Loan Documents.

      5. Representations and Warranties.

            (a) Borrower hereby represents and warrants that no Event of Default
or failure of condition has occurred or exists, or would exist with notice or
lapse of time or both under any of the Loan Agreement.

            (b) All representations and warranties of Borrower in this Agreement
and the other Loan Agreement are true and correct as of the date hereof, and
shall survive the execution of this Agreement.

      6. Default. In addition to all other Events of Default under the Loan
Agreement, the following shall constitute an Event of Default:

            (a) Borrower's failure to pay any amount when due under this
Agreement or to perform any covenant or other agreement contained in this
Agreement or any other document entered into pursuant hereto.

      7. Conditions Precedent. The effectiveness of this Agreement is subject to
receipt by Bank of the following, in each case in form and substance acceptable
to Bank:

            (a) This Agreement;

            (b) Payment of all Bank Expenses incurred in connection with this
Agreement; and

            (c) Such other documents and completion of such other matters as
Bank may reasonably deem necessary or appropriate.

      8. Release.

            (a) Borrower acknowledges that Bank would not enter into this
Agreement without Borrower's assurance that Borrower has no claims against Bank
or any of Bank's officers, directors, employees or agents. Except for the
obligations arising hereafter under this Agreement, Borrower releases Bank, any
person or entity that has obtained any interest from Bank under the Loan
Agreement and each of Bank's and entity's officers, directors and employees from
any known or unknown claims which Borrower now has against Bank of any nature,
including any claims that Borrower, its successors, counsel, and advisors may in
the future discover they would have now had if they had known facts not now
known to them, whether founded in contract, in tort or pursuant to any other
theory of liability,


                                       2
<PAGE>

including but not limited to any claims arising out of or related to the Loan
Agreement or the transactions contemplated thereby. Borrower waives the
provisions of California Civil Code section 1542, which states:

            A general release does not extend to claims which the creditor does
            not know or suspect to exist in his favor at the time of executing
            the release, which if known by him must have materially affected his
            settlement with the debtor.

            (b) The provisions, waivers and releases set forth in this section
are binding upon Borrower and Borrower's agents, employees, assigns and
successors in interest. The provisions, waivers and releases of this section
shall inure to the benefit of Bank and its agents, employees, officers,
directors, assigns and successors in interest.

            (c) Borrower warrants and represents that Borrower is the sole and
lawful owner of all right, title and interest in and to all of the claims
released hereby and Borrower has not heretofore voluntarily, by operation of law
or otherwise, assigned or transferred or purported to assign or transfer to any
person any such claim or any portion thereof. Borrower shall indemnify and hold
harmless Bank from and against any claim, demand, damage, debt, liability
(including payment of attorneys' fees and costs actually incurred whether or not
litigation is commenced) based on or arising out of any assignment or transfer.

            (d) The provisions of this Section shall survive payment in full of
the Obligations, full performance of all the terms of this Agreement and the
Loan Agreement, and/or Bank's actions to exercise any remedy available under the
Loan Agreement or otherwise.

      9. Further Assurances. Borrower will take such other actions as Bank may
reasonably request from time to time to perfect or continue Bank's security
interests in Borrower's property, and to accomplish the objectives of this
Agreement.

      10. Consultation of Counsel. Borrower acknowledges that Borrower has had
the opportunity to be represented by legal counsel of its own choice throughout
all of the negotiations that preceded the execution of this Agreement. Borrower
has executed this Agreement after reviewing and understanding each provision of
this Agreement and without reliance upon any promise or representation of any
person or persons acting for or on behalf of Bank. Borrower further acknowledges
that Borrower and its counsel have had adequate opportunity to make whatever
investigation or inquiry they may deem necessary or desirable in connection with
the subject matter of this Agreement prior to the execution hereof and the
delivery and acceptance of the consideration described herein.

      11. Miscellaneous.

            (a) Successors and Assigns. This Agreement shall be binding upon and
shall inure to the benefit of Borrower and Bank and their respective successors
and assigns; provided, however, that the foregoing shall not authorize any
assignment by Borrower of its rights or duties hereunder.

            (b) Integration. This Agreement and any documents executed in
connection herewith or pursuant hereto contain the entire agreement between the
parties with respect to the subject matter hereof and supersede all prior
agreements, understandings, offers and negotiations, oral or written, with
respect thereto and no extrinsic evidence whatsoever may be introduced in any
judicial or arbitration proceeding, if any, involving this Agreement; except
that any financing statements or other agreements or instruments filed by Bank
with respect to Borrower shall remain in full force and effect.


                                       3
<PAGE>

            (c) Entire Agreement. This Agreement and the Loan Documents contain
the entire agreement of the parties hereto and supersede any other oral or
written agreements or understandings with respect to the subject matter hereof
and thereof.

            (d) Course of Dealing; Waivers. No course of dealing on the part of
Bank or its officers, nor any failure or delay in the exercise of any right by
Bank, shall operate as a waiver thereof, and any single or partial exercise of
any such right shall not preclude any later exercise of any such right. Bank's
failure at any time to require strict performance by Borrower of any provision
shall not affect any right of Bank thereafter to demand strict compliance and
performance. Any suspension or waiver of a right must be in writing signed by an
officer of Bank.

            (e) Time is of the Essence. Time is of the essence as to each and
every term and provision of this Agreement and the Loan Documents.

            (f) Counterparts. This Agreement may be signed in counterparts and
all of such counterparts when properly executed by the appropriate parties
thereto together shall serve as a fully executed document, binding upon the
parties.

            (g) Legal Effect. The Loan Documents remain in full force and
effect. If any provision of this Agreement conflicts with applicable law, such
provision shall be deemed severed from this Agreement, and the balance of this
Agreement shall remain in full force and effect.

            (h) WAIVER OF JURY. BANK AND BORROWER ACKNOWLEDGE AND AGREE THAT THE
TIME AND EXPENSE REQUIRED FOR TRIAL BY JURY EXCEED THE TIME AND EXPENSE REQUIRED
FOR A BENCH TRIAL AND HEREBY WAIVE, TO THE EXTENT PERMITTED BY LAW, TRIAL BY
JURY OF ANY CLAIM OR CAUSE OF ACTION BASED UPON, RELATED TO OR ARISING OUT OF
THE TRANSACTIONS CONTEMPLATED BY THE LOAN AGREEMENT, INCLUDING CONTRACT CLAIMS,
TORT CLAIMS, BREACH OF DUTY CLAIMS, AND ALL OTHER COMMON LAW OR STATUTORY
CLAIMS. EACH PARTY RECOGNIZES AND AGREES THAT THE FOREGOING WAIVER CONSTITUTES A
MATERIAL INDUCEMENT FOR IT TO ENTER INTO THIS AGREEMENT. EACH PARTY REPRESENTS
AND WARRANTS THAT IT HAS REVIEWED THIS WAIVER WITH ITS LEGAL COUNSEL AND THAT IT
KNOWINGLY AND VOLUNTARILY WAIVES ITS JURY TRIAL RIGHTS FOLLOWING CONSULTATION
WITH LEGAL COUNSEL.

            (i) Assignment. Borrower consents to Bank's assignment of all or any
part of Bank's rights under this Agreement and the Loan Agreement.

            (j) Power of Attorney. Borrower confirms that the irrevocable power
of attorney granted in the Loan Agreement remains in full force and effect

            (k) Choice of Law and Venue. This Agreement shall be governed by,
and construed in accordance with, the internal laws of the State of California,
without regard to principles of conflicts of law. Each of Borrower and Bank
submits to the exclusive jurisdiction of the state and Federal courts located in
the County of Santa Clara, State of California.


                                       4
<PAGE>

      IN WITNESS WHEREOF the undersigned have executed this Agreement as of the
first date above written.

                                        PHARMCHEM, INC.


                                        By:     /S/ DAVID A. LATTANZIO
                                                ----------------------

                                        Title:  Vice President & CFO
                                                ----------------------



                                        COMERICA BANK-CALIFORNIA


                                        By:     /S/ JAMES L. WEBER
                                                ----------------------

                                        Title:  First Vice President
                                                ----------------------


                                       5