several api and tests fixes