Fixed error message, added tests for trailing Z