Refactor of threshold tests