fix bug #778 and #779 and add test
Merge branch 'master' of github.com:liuzelei/metroplex