Fix bugs and improve coverage for read only variables