Fixed error reporting when appending
There was a pointless raise that a test thought it was checking for, but
a different error was being raised than was intended. The logic also
used a lot of "unless"es which made it hard to follow at times, so
changed them to "if".