fixed some issues; cleanup; added more tests