Add tests for issues #35 and #38
Fix tests for issues #30 and #31