Fix some bugs on refactor code, after test