Fixed some bugs , dried out api implementation, tests are still failing