Last rule tests and some bug fixes