improve build script and add a test