adding tests and fixes