bug fix
improved tests