Fix white space and added method for invalid byte sequence
Fixed issue with invalid byte sequence, and added tests for it