Refactor and improve test cases (introduce relative error)