small refactors
extract client id logic and test