Refactor testing of rails-api