adding tests and adjusting functions