Extended testcase and buggfix