Fix for UT

And fixed stackoverflow