reduce char array copy and add test.