webscraping: refactoring and tests