add chaining method for both lib and move test.sh to test