Added tests for Sequence and fixed bugs.