Add previous api to simpliy code and resolve tests