Fix encoding and integration tests