refactored healthcheck and added test cases for it