Bugfix in TST and add unittest for it