Fix and refactor the mocha tests

I caught an error while working on https://github.com/reverb/swagger-spec/pull/86. The loop didn't work properly: it displayed the name of each file but actually tested the same file each time. I fixed that, and also cleaned things up in general.

This is working well for me now, as evidenced by being able to detect and fix all the issues in #86. However, JavaScript isn't my strongest language, so please feel free to improve this further.