Added tests & patch (along with a bit of refactoring) for issue #95: Changes should persist before sending