added tests for ring condition, fixed calculating ring condition