Chef-4481 Rebase including regression tests

> **Currently tracking in [CHEF-4481](https://tickets.opscode.com/browse/CHEF-4481) and [CHEF-4800](https://tickets.opscode.com/browse/CHEF-4800)**

This is a rebase of #960 with a slight refactoring to ensure correct behavior and additional regression tests.