This is one of those things that I think gets more complicated the more you try to simplify it.  In this case, if you moved line 53 to it's own file, you've now created a whole layer of complexity for one line.  If you try to move anything else, you now have to pass in the 'api' object, and worry about all the scoping that is done in this file.  I'll keep looking at it (since it's bothered me too), but I don't see a simple way to fix it.