add whole slew of tests, fix whole slew of bugs