Implemented API and added API tests