Refactor app and test