Refactor test API and implement changes in all tests