More test code. Minor functionality changes.