Fix issue#506
Wrote tests for issue #506
Added mkdirs() in setText method