Refactored for greater modularity
Added parser tests