Refactor app for testing