Made getBeforeFilters dynamic in Controller

When using more than one before filter on controller it would die as api-guard might have been second position in the array.
clean up
forgot to check the apiMethods key
Formatting changes