Scanner refactoring

Use `let name' for recursive function
Use line structure to manage line
Add documentation
Expose test to the world