[registry] small refactoring and added flush test