add gem code and tests with awkward rails initialization