Fix mistakes and add tests for tuples