Added unit tests and changing to poll() instead of take() to prevent locking threads