Add tests and improved parser