Finish adding tests. Move the app definition into a method, so it can be used in tests, and break out the handlers into their own modules.