move test related functions to lib/test.js
add missing testlib
add more test