fix bug in quickEncode, add more tests, finish assignment