Adding tests, and fixing resulting bugs found, and extensions needed