add more test cases, and fix a back referencing bug