#173 refactoring and tests update