more tests and defensive coding