write gaia test cases and fix some bugs.