Refactor and add specs for application_helper