Merge changes from topic "forResultFix" into main

* changes:
  Improve unit tests
  Only auto-opt in real caller