fixed typos and added test code