adding test and refactoring mapToDouble method