fixed a nasty nested looping bug, started adding tests
fixed breakage in messaging