Added recursive str replace to writer and updated test case