Fix use of negative numbers and add more tests