code cleanup; still no idea why tests do not succeed if run all at once