Code review: 180860043: Minor bug fixes in preg along with adding few tests and minor changes.