Fix block extending in parser

Closes  #1010.  This largely reverts #876 which introduced the problem.  It does however still keep the unit  tests and also fixes the problem, just in a totally different way.