Clean up and speed up ref attribute resolution

For my [schema validation benchmark](https://github.com/treppo/json-schema/blob/benchmarkin/bench/benchmark.rb), this change means a ~10% speedup. I extracted a few methods on the way to clean up.
that is the funny thing. profiling showed me, that these two gsubs are very slow as they are executed for all fragments. after a pull i saw, that there are new tests for it. surprisingly i was able to just remove them, with the tests still passing. i wonder why though, i was not able to find out.