Latest work

It is still pretty ugly, but at least with an integration test it seems to be doing its part.
There is a big catch in rails.