Tests for SA1000 diagnostic and code fix

Fixes #176 
Fixes #263 

Also includes fixes for small bugs which were identified by the tests.