String given to scope_t::append now returned from scope_t::back

Previously we would parse the string appended to an existing scope, meaning invalid scopes would not be returned as the same string.

Fixes #1099
Add debug code