Fixed undefined.toString issue. Improved test coverage.