Refactoring javascript for unit testing | Hacker News Reader