Improve and fix issue in unittests