Added tests with negative numbers, fixed work with negative numbers