add test suite for phase 1 and correct a bug