Added code to strip off unwanted characters from target dir name and
also moved out the test code from py file