finished stream refactoring and tests