update the build script for supporting multiple groovy versions
fix a problem the first test does not get System.out back to stdout
refactor and fix tests