Add regression test for #272
Fix similar issues and those test
Merge pull request #276 from defunkt/fix-similar-issues-272

Fix similar issues 272