further bug fixed and additional tests