add unit tests and finish configurable timeout