Debugging to fix e2e testing issue
Refactory a little bit.
Merge pull request #1424 from dchen1107/cleanup

Fix e2e testing issue