rewrites controller to be more testable
Merge pull request #2 from cahlan/master

rewrites controller to be more testable