Fixed trailing '\0' solution.

Added test for trailing ‘\0’ fix.