Clean up testing and refine before_filter.