Cleaned up build script and fixed breakages. Fixed test script.