[Refactoring] deferred is necessary only for nested functions in unittests

This is very trivial refactoring.