Bugfixes and tests for deferred