Add helper function to reduce code duplication

I was going through application_controller.erl looking for why
something was behaving a certain way, saw a comment about removing
this duplicated code one day, and decided to move that a step forward.