Fixed sleep errors, added test functionality and made a few other small modifications
merging