Added tests, added possibility of cancellation