Switch from bufio.Scanner to bufio.Reader; add a few tests

@nelhage — thoughts?