Added some integrations tests and found fixed some bugs