fixing bugs and running tests