Improve grammar modules

- return a table instead of just the grammar
- add time_ns utility function
- add additional unit tests