Test coverage utils and fixing minor bugs