made some changes to handle null character and added some tests to check our error handling