Fixing error.
Improved error message
Adding more test cases. Fixing shell IO handling. Adding error handling.