Added some tests; fixed shifting algorithm