write gaia stack's test case and fix some bugs.