fix Q module and adds some tests