Add test script and fix a few errors.