Improve the error position reporting and add test specs for each of the cases.