improves naive solution:

- adds tests
- improved regexps
- handles commented out lines in source
- keeps order of requires