Fix account clear reference issue and add UT
Merge pull request #950 from andrerod/dev

Fix account clear reference issue and add UT