refactored tests and improvements on task API