Some refactoring to make strategy.js easier to test, and adding some more coverage