Fixed a bug in appending strings and added some relevant tests

It's fine in ```master```. Maybe occurred when merging.