fixed edge case logic, added rivet tests