Fix self-join errors
Change test case accordingly
Merge pull request #690 from maryannxue/master

Fix issue#689 Self-join does not work