Small code cleanup and moving files from app to lib

Mostly to fix a dependency issue I was getting when trying to test openstax_api.
The engine itself requires Rails as well:

`class Engine < ::Rails::Engine`