fixing bugs and erroneous tests