Fixed bug; updated unit tests