Several small corrections to make it run and tests pass in rails4