Updated to support directories
Added testcase