Restructure tests again and get API tests working