refactoring and more consistent test passing