Refactoring javascript for unit testing | Dark Hacker News