Fixed a couple bugs in test and code.