refactored charset extraction, added tests, comments and a CHANGELOG