Added Threshold API and TESTS