minor corrections, and a test function