fixes #59: redesigned path calculation, supported options.main in
fixes #58: add test cases