refactor, preparing scrounge.js script for unit tests