finish integration test and some bug fix