Fixed #113 and #153 by using the expanduser from os.path
Support '~' by using expanduser from os.path
edit some test cases