Added unit test; fixed broken code.