Cleanup and added unit tests

- Minor cleanup
- Added unit tests for the reg exp matching.