Added test and make error messages more comprehensive.
Added type hinting