refactor test move check error to assertError function
move test server to function