Bug when trying to download attachment (#1310)

Includes refactoring and style fixes.
Ref
https://github.com/TheWeatherCompany/grid-api/issues/1310