Cherry pick fixes develop to fix unit test

The fix was applied to develop in #488 . Cherry picking those commits into release branch to avoid release branch unit-test keeps failing.